mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 06:48:37 +02:00
add eslint example
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
12
eslint-example/.eslintrc.json
Normal file
12
eslint-example/.eslintrc.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"plugins": [
|
||||
"mozilla"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:mozilla"
|
||||
],
|
||||
"rules": {
|
||||
"no-set-state": "off"
|
||||
}
|
||||
}
|
||||
15
eslint-example/file.js
Normal file
15
eslint-example/file.js
Normal file
@@ -0,0 +1,15 @@
|
||||
function getJSON(url, callback) {
|
||||
var one, two
|
||||
|
||||
|
||||
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)));
|
||||
}
|
||||
7
eslint-example/main.js
Normal file
7
eslint-example/main.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import {
|
||||
getUsefulContents
|
||||
} from "file";
|
||||
|
||||
getUsefulContents("http://www.example.com", data => {
|
||||
doSomethingUseful(data);
|
||||
});
|
||||
16
eslint-example/package.json
Normal file
16
eslint-example/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
Reference in New Issue
Block a user