diff --git a/eslint-example/.eslintrc.json b/eslint-example/.eslintrc.json index f589db7..8c8f0a2 100644 --- a/eslint-example/.eslintrc.json +++ b/eslint-example/.eslintrc.json @@ -2,11 +2,11 @@ "plugins": [ "mozilla" ], - "extends": [ - "eslint:recommended", - "plugin:mozilla" - ], + "rules": { "no-set-state": "off" + }, + "env": { + "es6": true } } \ No newline at end of file diff --git a/eslint-example/README.md b/eslint-example/README.md index fcfeed7..95a448d 100644 --- a/eslint-example/README.md +++ b/eslint-example/README.md @@ -2,4 +2,6 @@ ## What it shows -A project configured to use the [Mozilla ESlint configuration](https://www.npmjs.com/package/eslint-plugin-mozilla) \ No newline at end of file +A project configured to use the [Mozilla ESlint configuration](https://www.npmjs.com/package/eslint-plugin-mozilla) + +* to run locally configured eslint use `npm run lint` \ No newline at end of file diff --git a/eslint-example/file.js b/eslint-example/file.js index 830878b..b8a351f 100644 --- a/eslint-example/file.js +++ b/eslint-example/file.js @@ -1,12 +1,4 @@ -function getJSON(url, callback) { - let xhr = new XMLHttpRequest(); - xhr.onload = function() { - callback(this.responseText); - }; - xhr.open("GET", url, true); - xhr.send(); -} - -export function getUsefulContents(url, callback) { - getJSON(url, data => callback(JSON.parse(data))); +// we cant use export here +function getUsefulContents(callback) { + callback('Hello World'); } \ No newline at end of file diff --git a/eslint-example/icons/LICENSE b/eslint-example/icons/LICENSE new file mode 100644 index 0000000..20e821d --- /dev/null +++ b/eslint-example/icons/LICENSE @@ -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/. diff --git a/eslint-example/icons/page-32.png b/eslint-example/icons/page-32.png new file mode 100644 index 0000000..dae663d Binary files /dev/null and b/eslint-example/icons/page-32.png differ diff --git a/eslint-example/icons/page-48.png b/eslint-example/icons/page-48.png new file mode 100644 index 0000000..ba042cd Binary files /dev/null and b/eslint-example/icons/page-48.png differ diff --git a/eslint-example/main.js b/eslint-example/main.js index 73292b2..72a34ce 100644 --- a/eslint-example/main.js +++ b/eslint-example/main.js @@ -1,7 +1,12 @@ - import { - getUsefulContents - } from "file"; + // not supported in Firefox + // import { getUsefulContents } from "file"; - getUsefulContents("http://www.example.com", data => { - doSomethingUseful(data); - }); \ No newline at end of file + function start() { + getUsefulContents(data => { + var display = document.getElementById('display'); + + display.innerHTML = data; + }); + } + + document.addEventListener('DOMContentLoaded', start); \ No newline at end of file diff --git a/eslint-example/manifest.json b/eslint-example/manifest.json new file mode 100644 index 0000000..833787d --- /dev/null +++ b/eslint-example/manifest.json @@ -0,0 +1,19 @@ +{ + "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", + + "applications": { + "gecko": { + "id": "eslint-example@mozilla.org", + "strict_min_version": "49.0" + } + }, + + "browser_action": { + "default_icon": "icons/page-32.png", + "default_popup": "popup.html" + } +} \ No newline at end of file diff --git a/eslint-example/package.json b/eslint-example/package.json index 6b77a47..77e5f4f 100644 --- a/eslint-example/package.json +++ b/eslint-example/package.json @@ -1,16 +1,18 @@ { - "name": "eslint-example", - "version": "1.0.0", - "description": "", - "main": "index.js", - "dependencies": {}, - "devDependencies": { - "eslint": "^3.9.0", - "eslint-plugin-mozilla": "^0.2.3" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC" -} + "name": "eslint-example", + "version": "1.0.0", + "description": "", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "eslint": "^3.9.0", + "eslint-plugin-mozilla": "^0.2.3" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "eslint": "./node_modules/.bin/eslint", + "lint": "eslint ." + }, + "author": "", + "license": "ISC" +} \ No newline at end of file diff --git a/eslint-example/popup.html b/eslint-example/popup.html new file mode 100644 index 0000000..92abfaa --- /dev/null +++ b/eslint-example/popup.html @@ -0,0 +1,15 @@ + + + + + Pop-up + + +

Example.com

+ +
+ + + + + \ No newline at end of file