Skip to content

Commit 76b887d

Browse files
committed
fixing lint issues
1 parent 0a433ba commit 76b887d

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

.eslintrc.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
module.exports = {
22
"extends": "eslint:recommended",
33
"globals": {
4-
"Utils" : "writable",
4+
"Utils" : "writable", // defined in utils.js
55
"UART" : "readonly",
6-
"Puck" : "readonly"
6+
"Puck" : "readonly",
7+
"device" : "writable", // defined in index.js
8+
"appJSON" : "writable", // defined in index.js
9+
710
},
811
"rules": {
912
"indent": [

js/appinfo.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ function translateJS(options, app, code) {
7676
}
7777
} else if (tok.str.startsWith("`")) {
7878
// it's a tempated String! scan all clauses inside it and re-run on the JS in those
79-
var re = /\$\{[^}]*\}/g;
79+
let re = /\$\{[^}]*\}/g, match;
8080
while ((match = re.exec(tokenString)) != null) {
81-
var orig = match[0];
82-
var replacement = translateJS(options, app, orig.slice(2,-1));
81+
let orig = match[0];
82+
let replacement = translateJS(options, app, orig.slice(2,-1));
8383
tokenString = tokenString.substr(0,match.index+2) + replacement + tokenString.substr(match.index + orig.length-1);
8484
}
8585
}

js/comms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const Comms = {
115115
/* when connected, this is the name of the device we're connected to as far as Espruino is concerned
116116
(eg Bluetooth/USB/Serial1.println("Foo") ) */
117117
espruinoDevice : undefined,
118-
// ================================================================================
118+
// ================================================================================
119119
// Show a message on the screen (if available)
120120
showMessage : (txt) => {
121121
console.log(`<COMMS> showMessage ${JSON.stringify(txt)}`);

js/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function appJSONLoadedHandler() {
4949
});
5050
});
5151
let promise = Promise.resolve();
52-
if ("undefined" != typeof onAppJSONLoaded)
52+
if ("undefined" != typeof onAppJSONLoaded) /*global onAppJSONLoaded*/
5353
promise = promise.then(onAppJSONLoaded);
5454
// finally update what we're showing
5555
promise.then(function() {
@@ -989,12 +989,12 @@ function getAppsToUpdate(options) {
989989

990990
function refreshMyApps() {
991991
// if we've got a callback, call it first
992-
if ("function"==typeof onRefreshMyApps)
992+
if ("function"==typeof onRefreshMyApps) /*global onRefreshMyApps*/
993993
onRefreshMyApps();
994994
// Now update...
995995
let panelbody = document.querySelector("#myappscontainer .panel-body");
996996
let appsToUpdate = getAppsToUpdate(); // this writes canUpdate attributes to apps in device.appsInstalled
997-
panelbody.innerHTML = device.appsInstalled.sort(appSorterUpdatesFirst).map(appInstalled => {
997+
panelbody.innerHTML = device.appsInstalled.sort(Utils.appSorterUpdatesFirst).map(appInstalled => {
998998
let app = appNameToApp(appInstalled.id);
999999
return getAppHTML(app, appInstalled, "myapps");
10001000
}).join("");

js/utils.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,17 @@ const CODEPAGE_CONVERSIONS = {
176176
/// Convert any character that cannot be displayed by Espruino's built in fonts
177177
/// originally https://github.com/espruino/EspruinoAppLoaderCore/pull/11/files
178178
function convertStringToISO8859_1(originalStr) {
179-
var chars = originalStr.split('');
180-
for (var i = 0; i < chars.length; i++) {
181-
var ch = chars[i];
179+
let chars = originalStr.split('');
180+
for (let i = 0; i < chars.length; i++) {
181+
let ch = chars[i];
182182
if (CODEPAGE_CONVERSIONS[ch])
183183
chars[i] = CODEPAGE_CONVERSIONS[ch];
184184
else if (chars[i].charCodeAt() > 255) {
185185
console.log("Skipped conversion of char: '" + chars[i] + "'");
186186
chars[i] = "?";
187187
}
188188
}
189-
var translatedStr = chars.join('');
189+
let translatedStr = chars.join('');
190190
if (translatedStr != originalStr)
191191
console.log("Remapped text: "+originalStr+" -> "+translatedStr);
192192
return translatedStr;
@@ -281,9 +281,9 @@ function toJSString(s) {
281281
else if (ch==92) json += "\\\\"; // slash
282282
else if (ch<32 || ch==127 || ch==173 ||
283283
((ch>=0xC2) && (ch<=0xF4))) // unicode start char range
284-
json += "\\x"+(ch&255).toString(16).padStart(2,0);
284+
json += "\\x"+(ch&255).toString(16).padStart(2,0);
285285
else if (ch>255)
286-
json += "\\u"+(ch&65535).toString(16).padStart(4,0);
286+
json += "\\u"+(ch&65535).toString(16).padStart(4,0);
287287
else json += s[i];
288288
}
289289
return json + "\"";
@@ -335,17 +335,17 @@ function searchRelevance(value, searchString) {
335335
relevance += 5;
336336
}
337337
// compare string parts
338-
var partRelevance = 0;
339-
var valueParts = value.split(/[\s(),.-]/).filter(p=>p.length);
338+
let partRelevance = 0;
339+
let valueParts = value.split(/[\s(),.-]/).filter(p=>p.length);
340340
searchString.split(/[\s-(),.-]/).forEach(search=>{
341341
valueParts.forEach(v=>{
342342
if (v==search)
343-
partRelevance += 20; // if a complete match, +20
343+
partRelevance += 20; // if a complete match, +20
344344
else {
345345
if (v.includes(search)) // the less of the string matched, lower relevance
346-
partRelevance += Math.max(0, 10 - (v.length - search.length));
346+
partRelevance += Math.max(0, 10 - (v.length - search.length));
347347
if (v.startsWith(search)) // add a bit of the string starts with it
348-
partRelevance += 10;
348+
partRelevance += 10;
349349
}
350350
});
351351
});

0 commit comments

Comments
 (0)