Skip to content

Commit 993d993

Browse files
committed
lint errors
1 parent 76b887d commit 993d993

File tree

4 files changed

+55
-48
lines changed

4 files changed

+55
-48
lines changed

lib/apploader.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/* Node.js library with utilities to handle using the app loader from node.js */
2+
/*global exports,global,__dirname,require,Promise */
23

3-
var DEVICEID = "BANGLEJS2";
4-
var VERSION = "2v11";
5-
var MINIFY = true; // minify JSON?
6-
var BASE_DIR = __dirname + "/../..";
7-
var APPSDIR = BASE_DIR+"/apps/";
4+
let DEVICEID = "BANGLEJS2";
5+
let VERSION = "2v11";
6+
let MINIFY = true; // minify JSON?
7+
let BASE_DIR = __dirname + "/../..";
8+
let APPSDIR = BASE_DIR+"/apps/";
89

910
//eval(require("fs").readFileSync(__dirname+"../core/js/utils.js"));
10-
var Espruino = require(__dirname + "/../../core/lib/espruinotools.js");
11+
let Espruino = require(__dirname + "/../../core/lib/espruinotools.js");
1112
//eval(require("fs").readFileSync(__dirname + "/../../core/lib/espruinotools.js").toString());
1213
//eval(require("fs").readFileSync(__dirname + "/../../core/js/utils.js").toString());
13-
var AppInfo = require(__dirname+"/../../core/js/appinfo.js");
14+
let AppInfo = require(__dirname+"/../../core/js/appinfo.js");
1415

15-
var SETTINGS = {
16+
let SETTINGS = {
1617
pretokenise : true
1718
};
1819
global.Const = {
@@ -22,9 +23,10 @@ global.Const = {
2223
SINGLE_APP_ONLY : false,
2324
};
2425

25-
var apps = [];
26-
var device = { id : DEVICEID, appsInstalled : [] };
27-
var language; // Object of translations
26+
let apps = [];
27+
// eslint-disable-next-line no-redeclare
28+
let device = { id : DEVICEID, appsInstalled : [] };
29+
let language; // Object of translations
2830

2931
/* This resets the list of installed apps to an empty list.
3032
It can be used in case the device behind the apploader has changed
@@ -53,18 +55,18 @@ exports.init = function(options) {
5355
// Try loading from apps.json
5456
apps.length=0;
5557
try {
56-
var appsStr = require("fs").readFileSync(BASE_DIR+"/apps.json");
57-
var appList = JSON.parse(appsStr);
58+
let appsStr = require("fs").readFileSync(BASE_DIR+"/apps.json");
59+
let appList = JSON.parse(appsStr);
5860
appList.forEach(a => apps.push(a));
5961
} catch (e) {
6062
console.log("Couldn't load apps.json", e.toString());
6163
}
6264
// Load app metadata from each app
6365
if (!apps.length) {
6466
console.log("Loading apps/.../metadata.json");
65-
var dirs = require("fs").readdirSync(APPSDIR, {withFileTypes: true});
67+
let dirs = require("fs").readdirSync(APPSDIR, {withFileTypes: true});
6668
dirs.forEach(dir => {
67-
var appsFile;
69+
let appsFile;
6870
if (dir.name.startsWith("_example") || !dir.isDirectory())
6971
return;
7072
try {
@@ -85,14 +87,14 @@ exports.apps = apps;
8587
function fileGetter(url) {
8688
url = BASE_DIR+"/"+url;
8789
console.log("Loading "+url)
88-
var data;
90+
let data;
8991
if (MINIFY && url.endsWith(".json")) {
90-
var f = url.slice(0,-5);
92+
let f = url.slice(0,-5);
9193
console.log("MINIFYING JSON "+f);
92-
var j = eval("("+require("fs").readFileSync(url).toString("binary")+")");
94+
let j = eval("("+require("fs").readFileSync(url).toString("binary")+")");
9395
data = JSON.stringify(j); // FIXME we can do better for Espruino
9496
} else {
95-
var blob = require("fs").readFileSync(url);
97+
let blob = require("fs").readFileSync(url);
9698
if (url.endsWith(".js") || url.endsWith(".json"))
9799
data = blob.toString(); // allow JS/etc to be written in UTF-8
98100
else
@@ -102,14 +104,14 @@ function fileGetter(url) {
102104
}
103105

104106
exports.getAppFiles = function(app) {
105-
var allFiles = [];
106-
var getFileOptions = {
107+
let allFiles = [];
108+
let getFileOptions = {
107109
fileGetter : fileGetter,
108110
settings : SETTINGS,
109111
device : { id : DEVICEID, version : VERSION },
110112
language : language
111113
};
112-
var uploadOptions = {
114+
let uploadOptions = {
113115
apps : apps,
114116
needsApp : app => {
115117
if (app.provides_modules) {

lib/customize.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function sendCustomizedApp(app, options) {
7171
}
7272

7373
let __id = 0, __idlookup = [];
74+
// eslint-disable-next-line no-redeclare
7475
const Puck = {
7576
eval : function(data,callback) {
7677
__id++;
@@ -94,6 +95,7 @@ const Puck = {
9495
this.handlers[id].forEach(cb => cb(data));
9596
}
9697
};
98+
// eslint-disable-next-line no-redeclare
9799
const UART = Puck;
98100

99101
const Util = {
@@ -154,6 +156,7 @@ const Util = {
154156
Util.domModal.classList.remove("active");
155157
},
156158
saveFile : function saveFile(filename, mimeType, dataAsString) {
159+
/*global Android*/
157160
if (typeof Android !== "undefined" && typeof Android.saveFile === 'function') {
158161
// Recent Gadgetbridge version that provides the saveFile interface
159162
Android.saveFile(filename, mimeType, btoa(dataAsString));
@@ -206,12 +209,10 @@ function atobSafe(input) {
206209
// This code was written by Tyler Akins and has been placed in the
207210
// public domain. It would be nice if you left this header intact.
208211
// Base64 code from Tyler Akins -- http://rumkin.com
209-
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
210-
211-
var output = '';
212-
var chr1, chr2, chr3;
213-
var enc1, enc2, enc3, enc4;
214-
var i = 0;
212+
let keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
213+
let output = '';
214+
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
215+
let i = 0;
215216
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
216217
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
217218
do {

lib/emulator.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
/* Node.js library with utilities to handle using the emulator from node.js */
2+
/*global exports,__dirname,Promise,require,Uint8Array,Uint32Array */
3+
/*global jsRXCallback:writable,jsUpdateGfx:writable,jsTransmitString,jsInit,jsIdle,jsStopIdle,jsGetGfxContents,flashMemory */
4+
/*global FLASH_SIZE,GFX_WIDTH,GFX_HEIGHT */
25

3-
var EMULATOR = "banglejs2";
4-
var DEVICEID = "BANGLEJS2";
6+
let EMULATOR = "banglejs2";
7+
let DEVICEID = "BANGLEJS2";
58

6-
var BASE_DIR = __dirname + "/../..";
7-
var DIR_IDE = BASE_DIR + "/../EspruinoWebIDE";
9+
let BASE_DIR = __dirname + "/../..";
10+
let DIR_IDE = BASE_DIR + "/../EspruinoWebIDE";
811

912
/* we factory reset ONCE, get this, then we can use it to reset
1013
state quickly for each new app */
11-
var factoryFlashMemory;
14+
let factoryFlashMemory;
1215

1316
// Log of messages from app
14-
var appLog = "";
15-
var lastOutputLine = "";
16-
var consoleOutputCallback;
17+
let appLog = "";
18+
let lastOutputLine = "";
19+
let consoleOutputCallback;
1720

1821
function onConsoleOutput(txt) {
1922
appLog += txt + "\n";
@@ -98,25 +101,25 @@ exports.getLastLine = function() {
98101

99102
// Gets the screenshot as RGBA Uint32Array
100103
exports.getScreenshot = function() {
101-
var rgba = new Uint8Array(exports.GFX_WIDTH*exports.GFX_HEIGHT*4);
104+
let rgba = new Uint8Array(exports.GFX_WIDTH*exports.GFX_HEIGHT*4);
102105
exports.getGfxContents(rgba);
103-
var rgba32 = new Uint32Array(rgba.buffer);
106+
let rgba32 = new Uint32Array(rgba.buffer);
104107
return rgba32;
105108
}
106109

107110
// Write the screenshot to a file options={errorIfBlank}
108111
exports.writeScreenshot = function(imageFn, options) {
109112
options = options||{};
110113
return new Promise((resolve,reject) => {
111-
var rgba32 = exports.getScreenshot();
114+
let rgba32 = exports.getScreenshot();
112115

113116
if (options.errorIfBlank) {
114-
var firstPixel = rgba32[0];
115-
var blankImage = rgba32.every(col=>col==firstPixel);
117+
let firstPixel = rgba32[0];
118+
let blankImage = rgba32.every(col=>col==firstPixel);
116119
if (blankImage) reject("Image is blank");
117120
}
118121

119-
var Jimp = require("jimp");
122+
let Jimp = require("jimp");
120123
let image = new Jimp(exports.GFX_WIDTH, exports.GFX_HEIGHT, function (err, image) {
121124
if (err) throw err;
122125
let buffer = image.bitmap.data;

lib/interface.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Util.showModal(title) // show a modal screen over ever
4444
Util.hideModal() // hide the modal from showModal
4545
*/
4646
let __id = 0, __idlookup = [];
47+
// eslint-disable-next-line no-redeclare
4748
const Puck = {
4849
eval : function(data,callback) {
4950
__id++;
@@ -67,6 +68,7 @@ const Puck = {
6768
this.handlers[id].forEach(cb => cb(data));
6869
}
6970
};
71+
// eslint-disable-next-line no-redeclare
7072
const UART = Puck;
7173

7274
const Util = {
@@ -127,6 +129,7 @@ const Util = {
127129
Util.domModal.classList.remove("active");
128130
},
129131
saveFile : function saveFile(filename, mimeType, dataAsString) {
132+
/*global Android*/
130133
if (typeof Android !== "undefined" && typeof Android.saveFile === 'function') {
131134
// Recent Gadgetbridge version that provides the saveFile interface
132135
Android.saveFile(filename, mimeType, btoa(dataAsString));
@@ -179,12 +182,10 @@ function atobSafe(input) {
179182
// This code was written by Tyler Akins and has been placed in the
180183
// public domain. It would be nice if you left this header intact.
181184
// Base64 code from Tyler Akins -- http://rumkin.com
182-
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
183-
184-
var output = '';
185-
var chr1, chr2, chr3;
186-
var enc1, enc2, enc3, enc4;
187-
var i = 0;
185+
let keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
186+
let output = '';
187+
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
188+
let i = 0;
188189
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
189190
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
190191
do {

0 commit comments

Comments
 (0)