From cc5806e482ece6aa937dd604ef28ab2a912e9f56 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Wed, 4 Jan 2023 19:34:48 -0800 Subject: [PATCH] Fix ESLint warnings (and one actual bug) --- basic.js | 6 +++--- dos.js | 23 +++++++++-------------- hires.js | 8 ++++---- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/basic.js b/basic.js index 7ac7131..9e000f2 100644 --- a/basic.js +++ b/basic.js @@ -1233,7 +1233,7 @@ this.basic = (function() { (function(source) { function munge(kw) { // Escape special characters - function escape(c) { return (/[\[\]\\\^\$\.\|\?\*\+\(\)]/).test(c) ? '\\' + c : c; } + function escape(c) { return (/[[\]\\^$.|?*+()]/).test(c) ? '\\' + c : c; } // Allow linear whitespace between characters //return kw.split('').map(escape).join('[ \\t]*'); @@ -1268,9 +1268,9 @@ this.basic = (function() { var regexReservedWords = new RegExp("^(" + RESERVED_WORDS.map(munge).join("|") + ")", "i"), regexIdentifier = /^([A-Za-z][A-Za-z0-9]?)[A-Za-z0-9]*(\$|%)?/, regexStringLiteral = /^"([^"]*?)(?:"|(?=\n|\r|$))/, - regexNumberLiteral = /^[0-9]*\.?[0-9]+(?:[eE]\s*[\-+]?\s*[0-9]+)?/, + regexNumberLiteral = /^[0-9]*\.?[0-9]+(?:[eE]\s*[-+]?\s*[0-9]+)?/, regexHexLiteral = /^\$[0-9A-Fa-f]+/, - regexOperator = /^[;=<>+\-*\/\^(),]/, + regexOperator = /^[;=<>+\-*/^(),]/, regexLineNumber = /^[0-9]+/, regexSeparator = /^:/, diff --git a/dos.js b/dos.js index d69ebe2..f0a3e9c 100644 --- a/dos.js +++ b/dos.js @@ -151,18 +151,13 @@ function DOS(tty) { if (file === null) { // Not cached - do a synchronous XmlHttpRequest for the file here req = new XMLHttpRequest(); - try { - url = "vfs/" + encodeURIComponent(filename.replace(/\./g, '_')) + ".txt"; - async = false; - req.open("GET", url, async); - req.send(null); - if (req.status === 200 || req.status === 0) { // 0 for file:// protocol - file = req.responseText.replace(/\r\n/g, "\r"); - vfs_set(filename, file); - } - } catch (e) { - // File doesn't exist - APPEND/READ will fail - throw e; + url = "vfs/" + encodeURIComponent(filename.replace(/\./g, '_')) + ".txt"; + async = false; + req.open("GET", url, async); + req.send(null); + if (req.status === 200 || req.status === 0) { // 0 for file:// protocol + file = req.responseText.replace(/\r\n/g, "\r"); + vfs_set(filename, file); } } @@ -179,7 +174,7 @@ function DOS(tty) { // Normal open logic open(filename, recordlength); - if (!buffers.hasOwnProperty(filename)) { + if (!Object.prototype.hasOwnProperty.call(buffers, filename)) { doserror(DOSErrors.FILE_NOT_FOUND); } @@ -196,7 +191,7 @@ function DOS(tty) { // If not specified, close all buffers if (!filename) { for (fn in buffers) { - if (buffers.hasOwnProperty(fn)) { + if (Object.prototype.hasOwnProperty.call(buffers, fn)) { close(fn); } } diff --git a/hires.js b/hires.js index 0395672..f9ac2d2 100644 --- a/hires.js +++ b/hires.js @@ -87,7 +87,10 @@ function HiRes(element, width, height) { err = dx - dy, e2; - while (true) { + last_x = x; + last_y = y; + + for (;;) { this.plot(x0, y0); if (x0 === x1 && y0 === y1) { return; } @@ -101,9 +104,6 @@ function HiRes(element, width, height) { y0 += sy; } } - last_x = x; - last_y = y; - }; this.getPixel = function(x, y) {