Skip to content

Commit e270057

Browse files
authored
Merge pull request #192 from rikkuness/clean-up-lint-warnings
Clean up some more of the lint warnings
2 parents 5c8ce28 + 9f38197 commit e270057

File tree

11 files changed

+55
-52
lines changed

11 files changed

+55
-52
lines changed

core/flasher.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
console.log("Downloaded "+binary.byteLength+" bytes");
363363
flashBinaryToDevice(binary, flashOffset, callback, statusCallback);
364364
});
365-
};
365+
}
366366

367367

368368
function resetDevice(callback) {
@@ -417,9 +417,7 @@
417417
}, 2000/*timeout*/);
418418
});
419419
});
420-
};
421-
422-
420+
}
423421

424422
Espruino.Core.Flasher = {
425423
init : init,

core/flasherESP8266.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
(function(){
1414

1515
const BLOCK_SIZE = 0x400;
16-
var uart;
16+
// var uart;
1717
var uartLine = "";
1818
var packetHandler;
1919

@@ -166,7 +166,7 @@ function unsetupEspruino(options) {
166166
function cmdSync(options) {
167167
console.log("Syncing...");
168168
return new Promise((resolve,reject)=>{
169-
var success = false;
169+
// var success = false;
170170
var interval;
171171
packetHandler = function(d) {
172172
if (d.cmd==8) {

core/modules.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@
126126
console.log("loadModule("+fullModuleName+")");
127127

128128
var urls = []; // Array of where to look for this module
129-
var modName; // Simple name of the module
129+
// var modName; // Simple name of the module
130130
if(Espruino.Core.Utils.isURL(fullModuleName)) {
131-
modName = fullModuleName.substr(fullModuleName.lastIndexOf("/") + 1).split(".")[0];
131+
// modName = fullModuleName.substr(fullModuleName.lastIndexOf("/") + 1).split(".")[0];
132132
urls = [ fullModuleName ];
133133
} else {
134-
modName = fullModuleName;
134+
// modName = fullModuleName;
135135
Espruino.Config.MODULE_URL.split("|").forEach(function (url) {
136136
url = url.trim();
137137
if (url.length!=0)
138138
Espruino.Config.MODULE_EXTENSIONS.split("|").forEach(function (extension) {
139139
urls.push(url + "/" + fullModuleName + extension);
140140
})
141141
});
142-
};
142+
}
143143

144144
// Recursively go through all the urls
145145
(function download(urls) {
@@ -234,7 +234,7 @@
234234
callback(loadedModuleData.join("\n") + "\n" + code);
235235
});
236236
}
237-
};
237+
}
238238

239239

240240
Espruino.Core.Modules = {

core/serial_chrome_serial.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Author: Gordon Williams ([email protected])
3030
}
3131

3232
var connectionInfo;
33-
var connectedPort; // unused?
33+
// var connectedPort; // unused?
3434
var connectionDisconnectCallback;
3535
var connectionReadCallback;
3636

@@ -65,7 +65,7 @@ Author: Gordon Williams ([email protected])
6565
openCallback(undefined);
6666
} else {
6767
connectionInfo = cInfo;
68-
connectedPort = serialPort;
68+
// connectedPort = serialPort;
6969
console.log(cInfo);
7070
openCallback(cInfo);
7171
}

core/serial_web_audio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
connectionReadCallback(arr.buffer);
219219
}, 10);
220220
}
221-
};
221+
}
222222

223223
// ----------------------------------------------------------
224224

core/terminal.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
callback(data);
336336
});
337337

338-
};
338+
}
339339

340340
/* check for any terminal-inline-image and if they are still BMP
341341
then convert them to PNG using canvas */
@@ -430,7 +430,7 @@
430430
if (i in elements)
431431
elements[i].remove();
432432
// now write this to the screen
433-
var t = [];
433+
// var t = [];
434434
for (var y in termText) {
435435
var line = termText[y];
436436
if (y == termCursorY) {
@@ -483,7 +483,8 @@
483483
var pos = cursor[0].getBoundingClientRect();
484484
var terminalfocus = document.getElementById("terminalfocus");
485485
var x = Math.min(pos.left, terminal.offsetWidth);
486-
var y = Math.min(pos.top-tPos.top, terminal.height-terminalfocus.offsetHeight);
486+
// TODO: 'y' is already defined in outer scope, but this redeclaration doesn't appear to be used in this scope?
487+
var y = Math.min(pos.top-tPos.top, terminal.height-terminalfocus.offsetHeight);
487488
terminalfocus.style.left=x+"px";
488489
terminalfocus.style.top=(pos.top-tPos.top)+"px";
489490
}
@@ -495,8 +496,6 @@
495496
return str.substr(0,s+1);
496497
}
497498

498-
499-
500499
var handleReceivedCharacter = function (/*char*/ch) {
501500
function isUTF8StartChar(ch) {
502501
return (ch>=0xC2) && (ch<=0xF4);
@@ -612,7 +611,7 @@
612611
var old = onInputData;
613612
onInputData = callback;
614613
return old;
615-
};
614+
}
616615

617616
/// Called when data comes OUT of Espruino INTO the terminal
618617
function outputDataHandler(readData) {
@@ -632,7 +631,7 @@
632631
displayData = [];
633632
displayTimeout = null;
634633
}, 50);
635-
};
634+
}
636635

637636
var receivedData = "";
638637
function searchData(bytes){
@@ -661,36 +660,36 @@
661660
});
662661
// Ensure that data from Espruino goes to this terminal
663662
Espruino.Core.Serial.startListening(Espruino.Core.Terminal.outputDataHandler);
664-
};
663+
}
665664

666665
/// Get the current terminal line that we're on
667666
function getCurrentLine() {
668667
return termText.length-1;
669-
};
668+
}
670669

671670
/// Set extra text to display before a certain terminal line
672671
function setExtraText(line, text) {
673672
if (termExtraText[line] != text) {
674673
termExtraText[line] = text;
675674
updateTerminal();
676675
}
677-
};
676+
}
678677

679678
/// Clear all extra text that is to be displayed
680679
function clearExtraText() {
681680
termExtraText = {};
682681
updateTerminal();
683-
};
682+
}
684683

685684
/// Does the terminal have focus?
686685
function hasFocus() {
687686
return document.querySelector("#terminal").classList.contains("focus");
688-
};
687+
}
689688

690689
/// Give the terminal focus
691690
function focus() {
692691
document.getElementById("terminalfocus").focus();
693-
};
692+
}
694693

695694
// Is the terminal actually visible, or is it so small it can't be seen?
696695
function isVisible() {
@@ -713,15 +712,15 @@
713712
while (line < termText.length && termText[line].substr(0,1)==":")
714713
text += "\n"+termText[line++].substr(1);
715714
return { line : startLine, text : text };
716-
};
715+
}
717716

718717
/** Get the Nth from latest line of text in the terminal (unlike getInputLine) */
719718
function getTerminalLine(n) {
720719
if (n===undefined) n=0;
721720
var line = termText.length-(1+n);
722721
if (line<0) return undefined;
723722
return termText[line];
724-
};
723+
}
725724

726725
/** Add a notification to the terminal (as HTML). If options.buttonclick is set
727726
then the first <button> inside the notification text

core/utils.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
}
2121

22-
function decodeBase64(d) {
23-
return Buffer.from(d,'base64').toString('binary');
24-
}
22+
// function decodeBase64(d) {
23+
// return Buffer.from(d,'base64').toString('binary');
24+
// }
2525

26-
function encodeBase64(d) {
27-
return Buffer.from(d,'binary').toString('base64');
28-
}
26+
// function encodeBase64(d) {
27+
// return Buffer.from(d,'binary').toString('base64');
28+
// }
2929

3030
function isWindows() {
3131
return (typeof navigator!="undefined") && navigator.userAgent.indexOf("Windows")>=0;
@@ -118,7 +118,7 @@
118118
while (s.length < len) s+=" ";
119119
return s;
120120
}
121-
};
121+
}
122122

123123
/** Get a Lexer to parse JavaScript - this is really very nasty right now and it doesn't lex even remotely properly.
124124
* It'll return {type:"type", str:"chars that were parsed", value:"string", startIdx: Index in string of the start, endIdx: Index in string of the end}, until EOF when it returns undefined */
@@ -220,7 +220,7 @@
220220
if (ch=="\\") { // handle escape characters
221221
nextCh();
222222
var escape = '\\'+ch;
223-
var escapeExtra = 0;
223+
// var escapeExtra = 0;
224224
if (ch=="x") {
225225
nextCh();escape += ch;
226226
nextCh();escape += ch;
@@ -244,7 +244,7 @@
244244
value += ch;
245245
}
246246
nextCh();
247-
};
247+
}
248248
if (ch!==undefined) s+=ch;
249249
nextCh();
250250
}
@@ -260,7 +260,7 @@
260260
return {
261261
next : nextToken
262262
};
263-
};
263+
}
264264

265265
/** Count brackets in a string - will be 0 if all are closed */
266266
function countBrackets(str) {
@@ -331,7 +331,7 @@
331331
};
332332
// send a newline, and we hope we'll see '=undefined\r\n>'
333333
Espruino.Core.Serial.write('\n');
334-
};
334+
}
335335

336336
/** Return the value of executing an expression on the board. If
337337
If options.exprPrintsResult=false/undefined the actual value returned by the expression is returned.
@@ -436,7 +436,7 @@
436436
console.error("executeExpression called when not connected!");
437437
callback(undefined);
438438
}
439-
};
439+
}
440440

441441
// Download a file - storageFile or normal file
442442
function downloadFile(fileName, callback) {
@@ -476,7 +476,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
476476

477477
function versionToFloat(version) {
478478
return parseFloat(version.trim().replace("v","."));
479-
};
479+
}
480480

481481
/// Gets a URL, and returns callback(data) or callback(undefined) on error. options={method:"GET/POST", data:{a:1,b:2}}
482482
function getURL(url, callback, options) {
@@ -610,7 +610,6 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
610610
return window.location.protocol=="https:";
611611
}
612612

613-
614613
/* Open a file load dialog.
615614
options = {
616615
id : ID is to ensure that subsequent calls with the same ID remember the last used directory.
@@ -724,7 +723,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
724723
window.URL.revokeObjectURL(url);
725724
}, 0);
726725
}
727-
};
726+
}
728727

729728
/** Bluetooth device names that we KNOW run Espruino */
730729
var recongisedDevices = [
@@ -793,7 +792,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
793792
buf[i] = ch;
794793
}
795794
return buf.buffer;
796-
};
795+
}
797796

798797
// Converts a string to a Buffer
799798
function stringToBuffer(str) {
@@ -802,7 +801,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
802801
buf.writeUInt8(str.charCodeAt(i), i);
803802
}
804803
return buf;
805-
};
804+
}
806805

807806
// Converts a DataView to an ArrayBuffer
808807
function dataViewToArrayBuffer(dv) {
@@ -816,7 +815,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
816815
// Converts an ArrayBuffer to a string
817816
function arrayBufferToString(buf) {
818817
return String.fromCharCode.apply(null, new Uint8Array(buf));
819-
};
818+
}
820819

821820
/* Parses a JSON string into JS, taking into account some of the issues
822821
with Espruino's JSON from 2v04 and before */
@@ -834,7 +833,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
834833
tok = lex.next();
835834
}
836835
return JSON.parse(final);
837-
};
836+
}
838837

839838
/* Escape a string (like JSON.stringify) so that Espruino can understand it,
840839
however use \0,\1,\x,etc escapes whenever possible to make the String as small

plugins/assembler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@
480480
code;
481481
}
482482
callback(code);
483-
};
483+
}
484484

485485

486486
Espruino.Plugins.Assembler = {

plugins/compiler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@
5353
update node start/end positions of other nodes
5454
we're interested in */
5555
function replaceNode(node, newCode) {
56+
// TODO: Where is 'code' defined? Is this a global?
5657
code = code.substr(0,node.start) + newCode + code.substr(node.end);
5758
var offs = newCode.length - (node.end-node.start); // offset for future code snippets
59+
60+
// TODO: Also unclear where 'tasks' is defined, there's nothing in this scope to declare it
5861
for (var i in tasks)
5962
if (tasks[i].node.start > node.start) {
6063
tasks[i].node.start += offs;
@@ -67,7 +70,7 @@
6770
return callback(code);
6871

6972
var board = Espruino.Core.Env.getBoardData();
70-
var tasks = 0;
73+
var tasks = 0; // TODO: This is re-declared as an array at #73, but this outer scoped 'tasks' is not modified
7174
try {
7275
var ast = acorn.parse(code);
7376
var tasks = [];

plugins/minify.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@
194194
_callback(code);
195195
};
196196
})();
197+
198+
// TODO: None of the below block is called
197199
var minifyCode = code;
198200
var minifyCallback = callback;
199201
if (isModule) {
@@ -206,6 +208,7 @@
206208
callback(minified.substr(header.length, minified.length-(header.length+footer.length+1)));
207209
}
208210
}
211+
// End of unused block
209212

210213
switch(level){
211214
case "WHITESPACE_ONLY":

0 commit comments

Comments
 (0)