mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
create working extension with eslint configured locally
This commit is contained in:
@@ -2,11 +2,11 @@
|
|||||||
"plugins": [
|
"plugins": [
|
||||||
"mozilla"
|
"mozilla"
|
||||||
],
|
],
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:mozilla"
|
|
||||||
],
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-set-state": "off"
|
"no-set-state": "off"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"es6": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
## What it shows
|
## What it shows
|
||||||
|
|
||||||
A project configured to use the [Mozilla ESlint configuration](https://www.npmjs.com/package/eslint-plugin-mozilla)
|
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`
|
||||||
@@ -1,12 +1,4 @@
|
|||||||
function getJSON(url, callback) {
|
// we cant use export here
|
||||||
let xhr = new XMLHttpRequest();
|
function getUsefulContents(callback) {
|
||||||
xhr.onload = function() {
|
callback('Hello World');
|
||||||
callback(this.responseText);
|
|
||||||
};
|
|
||||||
xhr.open("GET", url, true);
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUsefulContents(url, callback) {
|
|
||||||
getJSON(url, data => callback(JSON.parse(data)));
|
|
||||||
}
|
}
|
||||||
2
eslint-example/icons/LICENSE
Normal file
2
eslint-example/icons/LICENSE
Normal 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/.
|
||||||
BIN
eslint-example/icons/page-32.png
Normal file
BIN
eslint-example/icons/page-32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 344 B |
BIN
eslint-example/icons/page-48.png
Normal file
BIN
eslint-example/icons/page-48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 310 B |
@@ -1,7 +1,12 @@
|
|||||||
import {
|
// not supported in Firefox
|
||||||
getUsefulContents
|
// import { getUsefulContents } from "file";
|
||||||
} from "file";
|
|
||||||
|
|
||||||
getUsefulContents("http://www.example.com", data => {
|
function start() {
|
||||||
doSomethingUseful(data);
|
getUsefulContents(data => {
|
||||||
});
|
var display = document.getElementById('display');
|
||||||
|
|
||||||
|
display.innerHTML = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', start);
|
||||||
19
eslint-example/manifest.json
Normal file
19
eslint-example/manifest.json
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint-example",
|
"name": "eslint-example",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^3.9.0",
|
"eslint": "^3.9.0",
|
||||||
"eslint-plugin-mozilla": "^0.2.3"
|
"eslint-plugin-mozilla": "^0.2.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
},
|
"eslint": "./node_modules/.bin/eslint",
|
||||||
"author": "",
|
"lint": "eslint ."
|
||||||
"license": "ISC"
|
},
|
||||||
}
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
15
eslint-example/popup.html
Normal file
15
eslint-example/popup.html
Normal 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>
|
||||||
Reference in New Issue
Block a user