Now linting library too

pull/461/head
Gordon Williams 2020-05-28 08:27:01 +01:00
parent e1c6123063
commit aa193454db
7 changed files with 44 additions and 14 deletions

View File

@ -1 +1,5 @@
js/espruinotools.js js/espruinotools.js
lib/imageconverter.js
lib/qrcode.min.js
lib/heatshrink.js

View File

@ -30,7 +30,7 @@ function toJS(txt) {
if ("undefined"!=typeof module) if ("undefined"!=typeof module)
Espruino = require("./espruinotools.js"); Espruino = require("./espruinotools.js");
let AppInfo = { const AppInfo = {
/* Get files needed for app. /* Get files needed for app.
options = { options = {
fileGetter : callback for getting URL, fileGetter : callback for getting URL,

View File

@ -1,7 +1,7 @@
Puck.debug=3; Puck.debug=3;
// FIXME: use UART lib so that we handle errors properly // FIXME: use UART lib so that we handle errors properly
let Comms = { const Comms = {
reset : (opt) => new Promise((resolve,reject) => { reset : (opt) => new Promise((resolve,reject) => {
Puck.write(`\x03\x10reset(${opt=="wipe"?"1":""});\n`, (result) => { Puck.write(`\x03\x10reset(${opt=="wipe"?"1":""});\n`, (result) => {
if (result===null) return reject("Connection failed"); if (result===null) return reject("Connection failed");

View File

@ -1,7 +1,7 @@
// General UI tools (progress bar, toast, prompt) // General UI tools (progress bar, toast, prompt)
/// Handle progress bars /// Handle progress bars
let Progress = { const Progress = {
domElement : null, // the DOM element domElement : null, // the DOM element
sticky : false, // Progress.show({..., sticky:true}) don't remove until Progress.hide({sticky:true}) sticky : false, // Progress.show({..., sticky:true}) don't remove until Progress.hide({sticky:true})
interval : undefined, // the interval used if Progress.show({progress:"animate"}) interval : undefined, // the interval used if Progress.show({progress:"animate"})

26
lib/.eslintrc.json Normal file
View File

@ -0,0 +1,26 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script"
},
"rules": {
"indent": [
"warn",
2,
{
"SwitchCase": 1
}
],
"no-undef": "warn",
"no-redeclare": "warn",
"no-var": "warn",
"no-unused-vars":"off" // we define stuff to use in other scripts
},
"env": {
"browser": true
},
"extends": "eslint:recommended",
"globals": {
"onInit" : "readonly"
}
}

View File

@ -19,8 +19,8 @@ Util.eraseStorageFile(filename,callback)
Util.showModal(title) Util.showModal(title)
Util.hideModal() Util.hideModal()
*/ */
var __id = 0, __idlookup = []; let __id = 0, __idlookup = [];
var Puck = { const Puck = {
eval : function(data,callback) { eval : function(data,callback) {
__id++; __id++;
__idlookup[__id] = callback; __idlookup[__id] = callback;
@ -32,7 +32,7 @@ var Puck = {
} }
}; };
var Util = { const Util = {
readStorageFile : function(filename,callback) { readStorageFile : function(filename,callback) {
__id++; __id++;
__idlookup[__id] = callback; __idlookup[__id] = callback;
@ -71,9 +71,9 @@ var Util = {
Util.domModal.classList.remove("active"); Util.domModal.classList.remove("active");
}, },
saveCSV : function(filename, csvData) { saveCSV : function(filename, csvData) {
var a = document.createElement("a"), let a = document.createElement("a"),
file = new Blob([csvData], {type: "Comma-separated value file"}); file = new Blob([csvData], {type: "Comma-separated value file"});
var url = URL.createObjectURL(file); let url = URL.createObjectURL(file);
a.href = url; a.href = url;
a.download = filename+".csv"; a.download = filename+".csv";
document.body.appendChild(a); document.body.appendChild(a);
@ -85,11 +85,11 @@ var Util = {
} }
}; };
window.addEventListener("message", function(event) { window.addEventListener("message", function(event) {
var msg = event.data; let msg = event.data;
if (msg.type=="init") { if (msg.type=="init") {
onInit(); onInit();
} else if (msg.type=="evalrsp" || msg.type=="writersp"|| msg.type=="readstoragefilersp") { } else if (msg.type=="evalrsp" || msg.type=="writersp"|| msg.type=="readstoragefilersp") {
var cb = __idlookup[msg.id]; let cb = __idlookup[msg.id];
delete __idlookup[msg.id]; delete __idlookup[msg.id];
cb(msg.data); cb(msg.data);
} }

View File

@ -9,7 +9,7 @@
}, },
"scripts": { "scripts": {
"lint-apps": "eslint ./apps --ext .js", "lint-apps": "eslint ./apps --ext .js",
"test": "node bin/sanitycheck.js && eslint ./apps --ext .js && eslint ./js", "test": "node bin/sanitycheck.js && eslint ./apps --ext .js && eslint ./lib ./js",
"start": "npx http-server" "start": "npx http-server"
}, },
"dependencies": { "dependencies": {