Merge pull request #128 from iampeterbanjo/eslint-example

Eslint example
This commit is contained in:
Kumar McMillan
2016-11-21 10:10:00 -06:00
committed by GitHub
11 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
{
"globals": {
"browser": true,
"chrome": true
},
"rules": {
"no-set-state": "off"
},
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended"
]
}

1
eslint-example/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules/

10
eslint-example/README.md Normal file
View File

@@ -0,0 +1,10 @@
# ESLint Example
## What it shows
A project configured to use the [Mozilla ESlint configuration](https://www.npmjs.com/package/eslint-plugin-mozilla). By using a linter on your extension source code you can be sure that you will only be writing JavaScript that is compatible with Firefox.
## How to use
* run `npm install` to install packages
* run `npm run lint` to use eslint

4
eslint-example/file.js Normal file
View File

@@ -0,0 +1,4 @@
/* exported getUsefulContents */
function getUsefulContents(callback) {
callback('Hello World');
}

View File

@@ -0,0 +1,2 @@
The "page-32.png" and "page-48.png" icons are taken from the miu iconset created by Linh Pham Thi Dieu, and are used under the terms of its license: http://linhpham.me/miu/.

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

10
eslint-example/main.js Normal file
View File

@@ -0,0 +1,10 @@
/* global getUsefulContents */
function start() {
getUsefulContents(data => {
var display = document.getElementById('display');
display.innerHTML = data;
});
}
document.addEventListener('DOMContentLoaded', start);

View File

@@ -0,0 +1,12 @@
{
"manifest_version": 2,
"description": "Example using eslint",
"name": "eslint-example",
"version": "1.0",
"homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/eslint-example",
"browser_action": {
"default_icon": "icons/page-32.png",
"default_popup": "popup.html"
}
}

View File

@@ -0,0 +1,16 @@
{
"name": "eslint-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"eslint": "^3.9.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ."
},
"author": "",
"license": "ISC"
}

15
eslint-example/popup.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pop-up</title>
</head>
<body>
<h1 id="title">Example.com</h1>
<div id="display"></div>
<script src="file.js"></script>
<script src="main.js"></script>
</body>
</html>