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
lib/imageconverter.js
lib/qrcode.min.js
lib/heatshrink.js

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// General UI tools (progress bar, toast, prompt)
/// Handle progress bars
let Progress = {
const Progress = {
domElement : null, // the DOM element
sticky : false, // Progress.show({..., sticky:true}) don't remove until Progress.hide({sticky:true})
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.hideModal()
*/
var __id = 0, __idlookup = [];
var Puck = {
let __id = 0, __idlookup = [];
const Puck = {
eval : function(data,callback) {
__id++;
__idlookup[__id] = callback;
@ -32,7 +32,7 @@ var Puck = {
}
};
var Util = {
const Util = {
readStorageFile : function(filename,callback) {
__id++;
__idlookup[__id] = callback;
@ -71,25 +71,25 @@ var Util = {
Util.domModal.classList.remove("active");
},
saveCSV : function(filename, csvData) {
var a = document.createElement("a"),
file = new Blob([csvData], {type: "Comma-separated value file"});
var url = URL.createObjectURL(file);
let a = document.createElement("a"),
file = new Blob([csvData], {type: "Comma-separated value file"});
let url = URL.createObjectURL(file);
a.href = url;
a.download = filename+".csv";
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
};
window.addEventListener("message", function(event) {
var msg = event.data;
let msg = event.data;
if (msg.type=="init") {
onInit();
} 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];
cb(msg.data);
}

View File

@ -9,7 +9,7 @@
},
"scripts": {
"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"
},
"dependencies": {