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": [
|
||||
"mozilla"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:mozilla"
|
||||
],
|
||||
|
||||
"rules": {
|
||||
"no-set-state": "off"
|
||||
},
|
||||
"env": {
|
||||
"es6": true
|
||||
}
|
||||
}
|
||||
@@ -3,3 +3,5 @@
|
||||
## What it shows
|
||||
|
||||
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) {
|
||||
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');
|
||||
}
|
||||
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 {
|
||||
getUsefulContents
|
||||
} from "file";
|
||||
// not supported in Firefox
|
||||
// import { getUsefulContents } from "file";
|
||||
|
||||
getUsefulContents("http://www.example.com", data => {
|
||||
doSomethingUseful(data);
|
||||
function start() {
|
||||
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"
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
"eslint-plugin-mozilla": "^0.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"eslint": "./node_modules/.bin/eslint",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"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