From 593a9240d799788248e9fd4ac5893531be2ec0a1 Mon Sep 17 00:00:00 2001 From: Tuukka Ikkala Date: Tue, 26 May 2020 15:10:34 +0300 Subject: [PATCH 1/2] eslint: Updated globals based on https://banglejs.com/reference --- apps/.eslintrc.json | 132 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 120 insertions(+), 12 deletions(-) diff --git a/apps/.eslintrc.json b/apps/.eslintrc.json index 4ed76396a..b92b5780d 100644 --- a/apps/.eslintrc.json +++ b/apps/.eslintrc.json @@ -1,28 +1,134 @@ { "env": { - "shared-node-browser": true + // TODO: "espruino": false + // TODO: "banglejs": false }, "extends": "eslint:recommended", "globals": { - "require": "readonly", - "process": "readonly", - "g": "writable", - "E": "readonly", + // Methods and Fields at https://banglejs.com/reference + "Array": "readonly", + "ArrayBuffer": "readonly", + "ArrayBufferView": "readonly", "Bangle": "readonly", + "BluetoothDevice": "readonly", + "BluetoothRemoteGATTCharacteristic": "readonly", + "BluetoothRemoteGATTServer": "readonly", + "BluetoothRemoteGATTService": "readonly", + "Boolean": "readonly", + "console": "readonly", + "DataView": "readonly", + "Date": "readonly", + "E": "readonly", + "Error": "readonly", + "Flash": "readonly", + "Float32Array": "readonly", + "Float64Array": "readonly", + "fs": "readonly", + "Function": "readonly", + "Graphics": "readonly", + "heatshrink": "readonly", + "I2C": "readonly", + "Int16Array": "readonly", + "Int32Array": "readonly", + "Int8Array": "readonly", + "InternalError": "readonly", + "JSON": "readonly", + "Math": "readonly", "Modules": "readonly", - "clearWatch": "readonly", - "setWatch": "readonly", - "getTime": "readonly", - "setTime": "readonly", + "NRF": "readonly", + "Number": "readonly", + "Object": "readonly", + "OneWire": "readonly", + "Pin": "readonly", + "process": "readonly", + "Promise": "readonly", + "ReferenceError": "readonly", + "RegExp": "readonly", + "Serial": "readonly", + "SPI": "readonly", + "Storage": "readonly", + "StorageFile": "readonly", + "String": "readonly", + "SyntaxError": "readonly", + "tensorflow": "readonly", + "TFMicroInterpreter": "readonly", + "TypeError": "readonly", + "Uint16Array": "readonly", + "Uint24Array": "readonly", + "Uint32Array": "readonly", + "Uint8Array": "readonly", + "Uint8ClampedArray": "readonly", + "Waveform": "readonly", + // Methods and Fields at https://banglejs.com/reference + "analogRead": "readonly", + "analogWrite": "readonly", + "arguments": "readonly", "atob": "readonly", - "load": "readonly", - "save": "readonly", + "Bluetooth": "readonly", + "BTN": "readonly", "BTN1": "readonly", "BTN2": "readonly", "BTN3": "readonly", "BTN4": "readonly", "BTN5": "readonly", - "NRF": "readonly", + "btoa": "readonly", + "changeInterval": "readonly", + "clearInterval": "readonly", + "clearTimeout": "readonly", + "clearWatch": "readonly", + "decodeURIComponent": "readonly", + "digitalPulse": "readonly", + "digitalRead": "readonly", + "digitalWrite": "readonly", + "dump": "readonly", + "echo": "readonly", + "edit": "readonly", + "encodeURIComponent": "readonly", + "eval": "readonly", + "getPinMode": "readonly", + "getSerial": "readonly", + "getTime": "readonly", + "global": "readonly", + "HIGH": "readonly", + "I2C1": "readonly", + "Infinity": "readonly", + "isFinite": "readonly", + "isNaN": "readonly", + "LED": "readonly", + "LED1": "readonly", + "LED2": "readonly", + "load": "readonly", + "LoopbackA": "readonly", + "LoopbackB": "readonly", + "LOW": "readonly", + "NaN": "readonly", + "parseFloat": "readonly", + "parseInt": "readonly", + "peek16": "readonly", + "peek32": "readonly", + "peek8": "readonly", + "pinMode": "readonly", + "poke16": "readonly", + "poke32": "readonly", + "poke8": "readonly", + "print": "readonly", + "require": "readonly", + "reset": "readonly", + "save": "readonly", + "Serial1": "readonly", + "setBusyIndicator": "readonly", + "setInterval": "readonly", + "setSleepIndicator": "readonly", + "setTime": "readonly", + "setTimeout": "readonly", + "setWatch": "readonly", + "shiftOut": "readonly", + "SPI1": "readonly", + "Terminal": "readonly", + "trace": "readonly", + "VIBRATE": "readonly", + // Aliases and not defined at https://banglejs.com/reference + "g": "readonly", "WIDGETS": "readonly" }, "parserOptions": { @@ -33,10 +139,12 @@ "no-constant-condition": "off", "no-delete-var": "off", "no-empty": "off", + "no-global-assign": "off", "no-inner-declarations": "off", "no-octal": "off", "no-prototype-builtins": "off", "no-redeclare": "off", + // TODO: "no-undef": "warn", "no-undef": "off", "no-unused-vars": "off", "no-useless-escape": "off" From d1b890c49a7d7282d8aaff7795e18b2ac6e8107e Mon Sep 17 00:00:00 2001 From: Tuukka Ikkala Date: Tue, 26 May 2020 15:21:43 +0300 Subject: [PATCH 2/2] npm test: Run eslint after sanitycheck.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c42a937b4..4b1a42c05 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "scripts": { "lint-apps": "eslint ./apps --ext .js", - "test": "node bin/sanitycheck.js", + "test": "node bin/sanitycheck.js && eslint ./apps --ext .js", "start": "npx http-server" }, "dependencies": {