]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Add eslint and fix reported issues
authorJuanjo Diaz <juanjo.diazmo@gmail.com>
Wed, 23 May 2018 21:25:44 +0000 (00:25 +0300)
committerJuanjo Diaz <juanjo.diazmo@gmail.com>
Wed, 23 May 2018 21:25:44 +0000 (00:25 +0300)
36 files changed:
.eslintrc [new file with mode: 0644]
app/localization.js
app/ui.js
app/webutil.js
core/base64.js
core/des.js
core/display.js
core/inflator.js
core/input/keyboard.js
core/input/mouse.js
core/input/util.js
core/rfb.js
core/util/browser.js
core/util/events.js
core/util/logging.js
core/util/strings.js
core/websock.js
package.json
tests/.eslintrc [new file with mode: 0644]
tests/assertions.js
tests/fake.websocket.js
tests/playback-ui.js
tests/playback.js
tests/test.base64.js
tests/test.helper.js
tests/test.keyboard.js
tests/test.localization.js
tests/test.mouse.js
tests/test.rfb.js
tests/test.util.js
tests/test.websock.js
tests/test.webutil.js
utils/.eslintrc [new file with mode: 0644]
utils/genkeysymdef.js
utils/use_require.js
utils/use_require_helpers.js

diff --git a/.eslintrc b/.eslintrc
new file mode 100644 (file)
index 0000000..b65b16c
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,14 @@
+{
+  "env": {
+    "browser": true,
+    "es6": true
+  },
+  "parserOptions": {
+    "sourceType": "module"
+  },
+  "extends": "eslint:recommended",
+  "rules": {
+      "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
+      "no-constant-condition": ["error", { "checkLoops": false }]
+  }
+}
index c43d407a8115bdd4e3016c5002f1d50f290b7cb8..43c1294d901a511cf3d694fe3a283d38e19d6d6b 100644 (file)
@@ -48,7 +48,8 @@ Localizer.prototype = {
             }
 
             // First pass: perfect match
-            for (var j = 0;j < supportedLanguages.length;j++) {
+            var j;
+            for (j = 0; j < supportedLanguages.length; j++) {
                 var supLang = supportedLanguages[j];
                 supLang = supLang.toLowerCase();
                 supLang = supLang.replace("_", "-");
@@ -64,7 +65,7 @@ Localizer.prototype = {
             }
 
             // Second pass: fallback
-            for (var j = 0;j < supportedLanguages.length;j++) {
+            for (j = 0;j < supportedLanguages.length;j++) {
                 supLang = supportedLanguages[j];
                 supLang = supLang.toLowerCase();
                 supLang = supLang.replace("_", "-");
index f3c6d46d416a75dae3d80fe9483b7a6122e3aec1..8515387a56b68231934089becd90ad703903b0d6 100644 (file)
--- a/app/ui.js
+++ b/app/ui.js
@@ -16,7 +16,6 @@ import KeyTable from "../core/input/keysym.js";
 import keysyms from "../core/input/keysymdef.js";
 import Keyboard from "../core/input/keyboard.js";
 import RFB from "../core/rfb.js";
-import Display from "../core/display.js";
 import * as WebUtil from "./webutil.js";
 
 var UI = {
@@ -1350,7 +1349,9 @@ var UI = {
             var l = input.value.length;
             // Move the caret to the end
             input.setSelectionRange(l, l);
-        } catch (err) {} // setSelectionRange is undefined in Google Chrome
+        } catch (err) {
+            // setSelectionRange is undefined in Google Chrome 
+        }
     },
 
     hideVirtualKeyboard: function() {
index 1087b330a22ebad7c540e19b471cce6573738677..73d24af043b5487ecb594272e22d69ffe6370ae1 100644 (file)
@@ -15,10 +15,10 @@ export function init_logging (level) {
     if (typeof level !== "undefined") {
         main_init_logging(level);
     } else {
-        var param = document.location.href.match(/logging=([A-Za-z0-9\._\-]*)/);
+        var param = document.location.href.match(/logging=([A-Za-z0-9._-]*)/);
         main_init_logging(param || undefined);
     }
-};
+}
 
 // Read a query string variable
 export function getQueryVar (name, defVal) {
@@ -31,7 +31,7 @@ export function getQueryVar (name, defVal) {
     } else {
         return defVal;
     }
-};
+}
 
 // Read a hash fragment variable
 export function getHashVar (name, defVal) {
@@ -44,7 +44,7 @@ export function getHashVar (name, defVal) {
     } else {
         return defVal;
     }
-};
+}
 
 // Read a variable from the fragment or the query string
 // Fragment takes precedence
@@ -55,7 +55,7 @@ export function getConfigVar (name, defVal) {
         val = getQueryVar(name, defVal);
     }
     return val;
-};
+}
 
 /*
  * Cookie handling. Dervied from: http://www.quirksmode.org/js/cookies.html
@@ -80,7 +80,7 @@ export function createCookie (name, value, days) {
         secure = "";
     }
     document.cookie = name + "=" + value + expires + "; path=/" + secure;
-};
+}
 
 export function readCookie (name, defaultValue) {
     "use strict";
@@ -93,12 +93,12 @@ export function readCookie (name, defaultValue) {
         if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); }
     }
     return (typeof defaultValue !== 'undefined') ? defaultValue : null;
-};
+}
 
 export function eraseCookie (name) {
     "use strict";
     createCookie(name, "", -1);
-};
+}
 
 /*
  * Setting handling.
@@ -122,12 +122,12 @@ export function initSettings (callback /*, ...callbackArgs */) {
             callback.apply(this, callbackArgs);
         }
     }
-};
+}
 
 // Update the settings cache, but do not write to permanent storage
 export function setSetting (name, value) {
     settings[name] = value;
-};
+}
 
 // No days means only for this browser session
 export function writeSetting (name, value) {
@@ -139,7 +139,7 @@ export function writeSetting (name, value) {
     } else {
         localStorage.setItem(name, value);
     }
-};
+}
 
 export function readSetting (name, defaultValue) {
     "use strict";
@@ -158,7 +158,7 @@ export function readSetting (name, defaultValue) {
     } else {
         return value;
     }
-};
+}
 
 export function eraseSetting (name) {
     "use strict";
@@ -173,7 +173,7 @@ export function eraseSetting (name) {
     } else {
         localStorage.removeItem(name);
     }
-};
+}
 
 export function injectParamIfMissing (path, param, value) {
     // force pretend that we're dealing with a relative path
@@ -203,7 +203,7 @@ export function injectParamIfMissing (path, param, value) {
     } else {
         return elem.pathname + elem.search + elem.hash;
     }
-};
+}
 
 // sadly, we can't use the Fetch API until we decide to drop
 // IE11 support or polyfill promises and fetch in IE11.
index 5182c29548986753a7c6d5fb441e39283d638bd1..48e28c313c640a2a1bc5bc6ef9bc3cb9bd2e09ed 100644 (file)
@@ -100,7 +100,7 @@ export default {
 
         // If there are any bits left, the base64 string was corrupted
         if (leftbits) {
-            err = new Error('Corrupted base64 string');
+            var err = new Error('Corrupted base64 string');
             err.name = 'Base64-Error';
             throw err;
         }
index 87dc516a05637bd7556d9ccce7f6e3d83592f504..821929b8c90345bd9e19567d053eedb031f25f0f 100644 (file)
@@ -268,4 +268,4 @@ export default function DES(passwd) {
     setKeys(passwd);             // Setup keys
     return {'encrypt': encrypt}; // Public interface
 
-}; // function DES
+}
index 99156157ac77db2d6f3219574d2bd03576a6bd06..7fed184bbeca7d88a88ac2b87207a06f6b1bd292 100644 (file)
@@ -68,7 +68,7 @@ export default function Display(target) {
 
     this._tile16x16 = this._drawCtx.createImageData(16, 16);
     Log.Debug("<< Display.constructor");
-};
+}
 
 var SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
 try {
index a4d6ff6a1d38638b0c1d67fe550f873a9a83a5c4..48fb71937c08d63c772b21505e6dc5607a1b854d 100644 (file)
@@ -35,4 +35,4 @@ export default function Inflate() {
     this.windowBits = 5;
 
     inflateInit(this.strm, this.windowBits);
-};
+}
index 72ff222e5fad611aa30379abe937448fe0d68bae..4ba36e3fecccd68c8acf69342d280c269caac117 100644 (file)
@@ -31,7 +31,7 @@ export default function Keyboard(target) {
         'blur': this._allKeysUp.bind(this),
         'checkalt': this._checkAlt.bind(this),
     };
-};
+}
 
 Keyboard.prototype = {
     // ===== EVENT HANDLERS =====
@@ -296,7 +296,7 @@ Keyboard.prototype = {
         Log.Debug(">> Keyboard.allKeysUp");
         for (var code in this._keyDownList) {
             this._sendKeyEvent(this._keyDownList[code], code, false);
-        };
+        }
         Log.Debug("<< Keyboard.allKeysUp");
     },
 
index 524b0653259aa4f046d6c387599a6bd4e2ba56f3..df9b7e1962356bf365322bda64caa8907ffdbeee 100644 (file)
@@ -32,7 +32,7 @@ export default function Mouse(target) {
         'mousewheel': this._handleMouseWheel.bind(this),
         'mousedisable': this._handleMouseDisable.bind(this)
     };
-};
+}
 
 Mouse.prototype = {
     // ===== PROPERTIES =====
index 96a5a233a839885c343634f05b6ca0f206735527..1201e1d79931d3e6682c7db5590d84374095e22d 100644 (file)
@@ -1,4 +1,3 @@
-import KeyTable from "./keysym.js";
 import keysyms from "./keysymdef.js";
 import vkeys from "./vkeys.js";
 import fixedkeys from "./fixedkeys.js";
index 2d7108d2481904e73133cf7f941c0e5405c9679b..652fbebf2b6147a93f149f6fe5cf8cf18e422a97 100644 (file)
@@ -25,9 +25,6 @@ import Inflator from "./inflator.js";
 import { encodings, encodingName } from "./encodings.js";
 import "./util/polyfill.js";
 
-/*jslint white: false, browser: true */
-/*global window, Util, Display, Keyboard, Mouse, Websock, Websock_native, Base64, DES, KeyTable, Inflator, XtScancode */
-
 // How many seconds to wait for a disconnect to finish
 var DISCONNECT_TIMEOUT = 3;
 
@@ -251,7 +248,7 @@ export default function RFB(target, url, options) {
     setTimeout(this._updateConnectionState.bind(this, 'connecting'));
 
     Log.Debug("<< RFB.constructor");
-};
+}
 
 RFB.prototype = {
     // ===== PROPERTIES =====
@@ -1063,7 +1060,7 @@ RFB.prototype = {
         var serverSupportedTypes = [];
 
         for (var i = 0; i < subAuthCount; i++) {
-            var capNum = this._sock.rQshift32();
+            this._sock.rQshift32(); // capNum
             var capabilities = this._sock.rQshiftStr(12);
             serverSupportedTypes.push(capabilities);
         }
@@ -2136,15 +2133,6 @@ RFB.encodingHandlers = {
         this._FBU.bytes = 1;  // compression-control byte
         if (this._sock.rQwait("TIGHT compression-control", this._FBU.bytes)) { return false; }
 
-        var checksum = function (data) {
-            var sum = 0;
-            for (var i = 0; i < data.length; i++) {
-                sum += data[i];
-                if (sum > 65536) sum -= 65536;
-            }
-            return sum;
-        };
-
         var resetStreams = 0;
         var streamId = -1;
         var decompress = function (data, expected) {
@@ -2564,6 +2552,7 @@ RFB.encodingHandlers = {
                 this._qemuExtKeyEventSupported = true;
             }
         } catch (err) {
+            // Do nothing
         }
     },
-};
+}
index 7a78eee05d31b33fd836d82782d9bc08f71fa760..2b44fb210c9fefe89462d82031baf2a490894189 100644 (file)
@@ -42,7 +42,7 @@ export function supportsCursorURIs () {
     }
 
     return _cursor_uris_supported;
-};
+}
 
 export function isMac() {
     return navigator && !!(/mac/i).exec(navigator.platform);
index 8efd0c23712c7e914b530d9ab90994796adff61c..270a558531d81c0c1f5f437f82b30dec1f0afe16 100644 (file)
 
 export function getPointerEvent (e) {
     return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e;
-};
+}
 
 export function stopEvent (e) {
     e.stopPropagation();
     e.preventDefault();
-};
+}
 
 // Emulate Element.setCapture() when not supported
 var _captureRecursion = false;
@@ -45,13 +45,13 @@ function _captureProxy(e) {
     if (e.type === "mouseup") {
         releaseCapture();
     }
-};
+}
 
 // Follow cursor style of target element
 function _captureElemChanged() {
     var captureElem = document.getElementById("noVNC_mouse_capture_elem");
     captureElem.style.cursor = window.getComputedStyle(_captureElem).cursor;
-};
+}
 var _captureObserver = new MutationObserver(_captureElemChanged);
 
 var _captureIndex = 0;
@@ -105,7 +105,7 @@ export function setCapture (elem) {
         window.addEventListener('mousemove', _captureProxy);
         window.addEventListener('mouseup', _captureProxy);
     }
-};
+}
 
 export function releaseCapture () {
     if (document.releaseCapture) {
@@ -135,4 +135,4 @@ export function releaseCapture () {
         window.removeEventListener('mousemove', _captureProxy);
         window.removeEventListener('mouseup', _captureProxy);
     }
-};
+}
index bcff16a50ba8198449dbe700ae8c577d1ccf2bb9..3b60f697cbbc2d9c7bbbf06eb49afaf744711ddb 100644 (file)
@@ -25,7 +25,9 @@ export function init_logging (level) {
     }
 
     Debug = Info = Warn = Error = function (msg) {};
+
     if (typeof window.console !== "undefined") {
+        /* eslint-disable no-console, no-fallthrough */
         switch (level) {
             case 'debug':
                 Debug = console.debug.bind(window.console);
@@ -40,11 +42,14 @@ export function init_logging (level) {
             default:
                 throw new Error("invalid logging type '" + level + "'");
         }
+        /* eslint-enable no-console, no-fallthrough */
     }
-};
+}
+
 export function get_logging () {
     return _log_level;
-};
+}
+
 export { Debug, Info, Warn, Error };
 
 // Initialize logging level
index 00a6156cda0db453c6e793b0d504db5dfca14610..d04ac00e952588c38308887d06d4aaefd3387cbb 100644 (file)
@@ -12,4 +12,4 @@
 export function decodeUTF8 (utf8string) {
     "use strict";
     return decodeURIComponent(escape(utf8string));
-};
+}
index a49591523b5032d1db2d8611535f1210e2dd908b..a5643dd3a1567511d8d2c782b166269c76187dbe 100644 (file)
@@ -37,7 +37,7 @@ export default function Websock() {
         'close': function () {},
         'error': function () {}
     };
-};
+}
 
 // this has performance issues in some versions Chromium, and
 // doesn't gain a tremendous amount of performance increase in Firefox
@@ -204,7 +204,6 @@ Websock.prototype = {
     },
 
     open: function (uri, protocols) {
-        var ws_schema = uri.match(/^([a-z]+):\/\//)[1];
         this.init();
 
         this._websocket = new WebSocket(uri, protocols);
@@ -267,7 +266,7 @@ Websock.prototype = {
         if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
             this._rQbufferSize = MAX_RQ_GROW_SIZE;
             if (this._rQbufferSize - this._rQlen - this._rQi < min_fit) {
-                throw new Exception("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
+                throw new Error("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
             }
         }
 
index 8a1e792ab0b0e7dd0c286af9e2d0cb810ca954a9..31c0e552772bbc47cc83e13af9fb6f71da5b9c67 100644 (file)
@@ -7,7 +7,8 @@
     "test": "tests"
   },
   "scripts": {
-    "test": "PATH=$PATH:node_modules/karma/bin karma start karma.conf.js",
+    "lint": "eslint app core po tests utils",
+    "test": "karma start karma.conf.js",
     "prepare": "node ./utils/use_require.js --as commonjs --clean"
   },
   "repository": {
@@ -40,6 +41,7 @@
     "chai": "^3.5.0",
     "commander": "^2.9.0",
     "es-module-loader": "^2.1.0",
+    "eslint": "^4.16.0",
     "fs-extra": "^1.0.0",
     "jsdom": "*",
     "karma": "^1.3.0",
diff --git a/tests/.eslintrc b/tests/.eslintrc
new file mode 100644 (file)
index 0000000..800dcf9
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "env": {
+    "node": true,
+    "mocha": true
+  },
+  "globals": {
+    "chai": true
+  }
+}
\ No newline at end of file
index a3d22c1e1bcf028126698ff3dcad9b9816890b4b..4f1cdc1787f2cae7559047716fbbd7ccb2cce08b 100644 (file)
@@ -20,6 +20,7 @@ chai.use(function (_chai, utils) {
             }
         }
         if (!same) {
+            // eslint-disable-next-line no-console
             console.log("expected data: %o, actual data: %o", target_data, data);
         }
         this.assert(same,
@@ -50,6 +51,7 @@ chai.use(function (_chai, utils) {
             }
         }
         if (!same) {
+            // eslint-disable-next-line no-console
             console.log("expected data: %o, actual data: %o", target_data, data);
         }
         this.assert(same,
index eb4f203dc5c8a33571ef7921389ee63a5ac53ec9..de3fb30a9330722755ad380c7ac9a9aeff2a6179 100644 (file)
@@ -1,3 +1,5 @@
+import Base64 from '../core/base64.js';
+
 // PhantomJS can't create Event objects directly, so we need to use this
 function make_event(name, props) {
     var evt = document.createEvent('Event');
@@ -27,7 +29,7 @@ export default function FakeWebSocket (uri, protocols) {
     this.bufferedAmount = 0;
 
     this.__is_fake = true;
-};
+}
 
 FakeWebSocket.prototype = {
     close: function (code, reason) {
@@ -75,6 +77,7 @@ FakeWebSocket.__is_fake = true;
 FakeWebSocket.replace = function () {
     if (!WebSocket.__is_fake) {
         var real_version = WebSocket;
+        // eslint-disable-next-line no-global-assign
         WebSocket = FakeWebSocket;
         FakeWebSocket.__real_version = real_version;
     }
@@ -82,6 +85,7 @@ FakeWebSocket.replace = function () {
 
 FakeWebSocket.restore = function () {
     if (WebSocket.__is_fake) {
+        // eslint-disable-next-line no-global-assign
         WebSocket = WebSocket.__real_version;
     }
 };
index a23b7faeca939ddcdc2e1d981c95fe9cf32e2260..84683cf167e671114adfa3e9f3e46fd28bc40ad0 100644 (file)
@@ -1,3 +1,5 @@
+/* global VNC_frame_data, VNC_frame_encoding */
+
 import * as WebUtil from '../app/webutil.js';
 import RecordingPlayer from './playback.js';
 
@@ -5,7 +7,6 @@ var frames = null;
 var encoding = null;
 
 function message(str) {
-    console.log(str);
     var cell = document.getElementById('messages');
     cell.textContent += str + "\n";
     cell.scrollTop = cell.scrollHeight;
index ddce444918f6411210f135d93480ae9bc2011054..7c9d7ff36cbcc9225389a048a55fb22f029d481d 100644 (file)
@@ -155,11 +155,12 @@ RecordingPlayer.prototype = {
 
         const frame = this._frames[this._frame_index];
         var start = frame.indexOf('{', 1) + 1;
+        var u8;
         if (this._encoding === 'base64') {
-            var u8 = Base64.decode(frame.slice(start));
+            u8 = Base64.decode(frame.slice(start));
             start = 0;
         } else {
-            var u8 = new Uint8Array(frame.length - start);
+            u8 = new Uint8Array(frame.length - start);
             for (let i = 0; i < frame.length - start; i++) {
                 u8[i] = frame.charCodeAt(start + i);
             }
index cfee409c8c0c7422d8b0d7df11a7f2e60b4e3f58..b87fdd2450fc9faca0009fc964592093664a7dcb 100644 (file)
@@ -1,4 +1,3 @@
-var assert = chai.assert;
 var expect = chai.expect;
 
 import Base64 from '../core/base64.js';
index 48e1def8f357b43fbda35aae9c1efe107b4449c9..1ab02fb6dc39f717646406b2969f4736dd5d8f9a 100644 (file)
@@ -1,5 +1,4 @@
-var assert = chai.assert;
-var expect = chai.expect;
+var expect = chai.expect;
 
 import keysyms from '../core/input/keysymdef.js';
 import * as KeyboardUtil from "../core/input/util.js";
index 78749f3919a2784e428f675e530673ed5a3cc98c..574f88edae7e1d9ab68ef4f21d1501516e895219 100644 (file)
@@ -1,4 +1,3 @@
-var assert = chai.assert;
 var expect = chai.expect;
 
 import sinon from '../vendor/sinon.js';
@@ -19,7 +18,7 @@ describe('Key Event Handling', function() {
         e.stopPropagation = sinon.spy();
         e.preventDefault = sinon.spy();
         return e;
-    };
+    }
 
     describe('Decode Keyboard Events', function() {
         it('should decode keydown events', function(done) {
@@ -133,12 +132,12 @@ describe('Key Event Handling', function() {
             });
             it('should suppress anything with a valid key', function() {
                 var kbd = new Keyboard(document, {});
-                var evt = keyevent('keydown', {code: 'KeyA', key: 'a'});
-                kbd._handleKeyDown(evt);
-                expect(evt.preventDefault).to.have.been.called;
-                evt = keyevent('keyup', {code: 'KeyA', key: 'a'});
-                kbd._handleKeyUp(evt);
-                expect(evt.preventDefault).to.have.been.called;
+                var evt1 = keyevent('keydown', {code: 'KeyA', key: 'a'});
+                kbd._handleKeyDown(evt1);
+                expect(evt1.preventDefault).to.have.been.called;
+                var evt2 = keyevent('keyup', {code: 'KeyA', key: 'a'});
+                kbd._handleKeyUp(evt2);
+                expect(evt2.preventDefault).to.have.been.called;
             });
             it('should not suppress keys without key', function() {
                 var kbd = new Keyboard(document, {});
@@ -148,11 +147,11 @@ describe('Key Event Handling', function() {
             });
             it('should suppress the following keypress event', function() {
                 var kbd = new Keyboard(document, {});
-                var evt = keyevent('keydown', {code: 'KeyA', keyCode: 0x41});
-                kbd._handleKeyDown(evt);
-                var evt = keyevent('keypress', {code: 'KeyA', charCode: 0x41});
-                kbd._handleKeyPress(evt);
-                expect(evt.preventDefault).to.have.been.called;
+                var evt1 = keyevent('keydown', {code: 'KeyA', keyCode: 0x41});
+                kbd._handleKeyDown(evt1);
+                var evt2 = keyevent('keypress', {code: 'KeyA', charCode: 0x41});
+                kbd._handleKeyPress(evt2);
+                expect(evt2.preventDefault).to.have.been.called;
             });
         });
     });
index bcaafcf048d886f242a026e9fd0920a0e3f105ef..adb29dbc9d69e3ef14f3e97845226e3ae80386f6 100644 (file)
@@ -1,7 +1,6 @@
-var assert = chai.assert;
 var expect = chai.expect;
 
-import l10nGet, { l10n } from '../app/localization.js';
+import { l10n } from '../app/localization.js';
 
 describe('Localization', function() {
     "use strict";
index efc2eed44522f668d5d94ce51b307caddedcaa29..d25913ccb19b79d9b3c02e46c5fff38baad6a63a 100644 (file)
@@ -1,4 +1,3 @@
-var assert = chai.assert;
 var expect = chai.expect;
 
 import sinon from '../vendor/sinon.js';
index 7f09416ab5b637b608bb5d6f271e324202e24701..eaf1366720a91f1f240885b3e5f8ed5fbd724805 100644 (file)
@@ -1,4 +1,3 @@
-var assert = chai.assert;
 var expect = chai.expect;
 
 import RFB from '../core/rfb.js';
@@ -658,16 +657,16 @@ describe('Remote Frame Buffer Protocol Client', function() {
         it('should not resize until the container size is stable', function () {
             container.style.width = '20px';
             container.style.height = '30px';
-            var event = new UIEvent('resize');
-            window.dispatchEvent(event);
+            var event1 = new UIEvent('resize');
+            window.dispatchEvent(event1);
             clock.tick(400);
 
             expect(RFB.messages.setDesktopSize).to.not.have.been.called;
 
             container.style.width = '40px';
             container.style.height = '50px';
-            var event = new UIEvent('resize');
-            window.dispatchEvent(event);
+            var event2 = new UIEvent('resize');
+            window.dispatchEvent(event2);
             clock.tick(400);
 
             expect(RFB.messages.setDesktopSize).to.not.have.been.called;
@@ -1894,7 +1893,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
                 });
 
                 it('should handle the DesktopSize pseduo-encoding', function () {
-                    var spy = sinon.spy();
                     sinon.spy(client._display, 'resize');
                     send_fbu_msg([{ x: 0, y: 0, width: 20, height: 50, encoding: -223 }], [[]], client);
 
@@ -1906,15 +1904,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
                 });
 
                 describe('the ExtendedDesktopSize pseudo-encoding handler', function () {
-                    var resizeSpy;
-
                     beforeEach(function () {
                         // a really small frame
                         client._fb_width = 4;
                         client._fb_height = 4;
                         client._display.resize(4, 4);
                         sinon.spy(client._display, 'resize');
-                        resizeSpy = sinon.spy();
                     });
 
                     function make_screen_data (nr_of_screens) {
@@ -2173,7 +2168,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
 
         describe('Keyboard Event Handlers', function () {
             it('should send a key message on a key press', function () {
-                var keyevent = {};
                 client._handleKeyEvent(0x41, 'KeyA', true);
                 var key_msg = {_sQ: new Uint8Array(8), _sQlen: 0, flush: function () {}};
                 RFB.messages.keyEvent(key_msg, 0x41, 1);
index 48345433649b383babe7f77e89a25a438155a60a..09c4ef0960b52caac36c558ecb3cc0e3ef9422de 100644 (file)
@@ -1,4 +1,4 @@
-var assert = chai.assert;
+/* eslint-disable no-console */
 var expect = chai.expect;
 
 import * as Log from '../core/util/logging.js';
@@ -68,3 +68,4 @@ describe('Utils', function() {
     //                     (we can't really test them against the browsers, except for Gecko
     //                     via PhantomJS, the default test driver)
 });
+/* eslint-enable no-console */
index 106639ababe63686398af97710e3e69464a400a7..1e978ec23ebdc1eac3a3f6060e32b71b11c3b42d 100644 (file)
@@ -1,4 +1,3 @@
-var assert = chai.assert;
 var expect = chai.expect;
 
 import Websock from '../core/websock.js';
@@ -231,14 +230,15 @@ describe('Websock', function() {
 
         var sock;
         beforeEach(function () {
-           sock = new Websock();
-           WebSocket = sinon.spy();
-           WebSocket.OPEN = old_WS.OPEN;
-           WebSocket.CONNECTING = old_WS.CONNECTING;
-           WebSocket.CLOSING = old_WS.CLOSING;
-           WebSocket.CLOSED = old_WS.CLOSED;
-
-           WebSocket.prototype.binaryType = 'arraybuffer';
+            sock = new Websock();
+            // eslint-disable-next-line no-global-assign
+            WebSocket = sinon.spy();
+            WebSocket.OPEN = old_WS.OPEN;
+            WebSocket.CONNECTING = old_WS.CONNECTING;
+            WebSocket.CLOSING = old_WS.CLOSING;
+            WebSocket.CLOSED = old_WS.CLOSED;
+
+            WebSocket.prototype.binaryType = 'arraybuffer';
         });
 
         describe('opening', function () {
@@ -327,6 +327,7 @@ describe('Websock', function() {
         });
 
         after(function () {
+            // eslint-disable-next-line no-global-assign
             WebSocket = old_WS;
         });
     });
index 3e894d52b183b234a5284270e3f6d1c1ec948662..27f982532e90572015d0b359585184024363b2f0 100644 (file)
@@ -1,6 +1,5 @@
 /* jshint expr: true */
 
-var assert = chai.assert;
 var expect = chai.expect;
 
 import * as WebUtil from '../app/webutil.js';
diff --git a/utils/.eslintrc b/utils/.eslintrc
new file mode 100644 (file)
index 0000000..b7dc129
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "env": {
+    "node": true
+  },
+  "rules": {
+       "no-console": 0
+  }
+}
\ No newline at end of file
index 8486da3964d33854f310625a70fad36e243622ae..8bce1ed3df980fcc4bb29aa8c9d7b8f4cf21d331 100755 (executable)
@@ -13,7 +13,8 @@ var fs = require('fs');
 var show_help = process.argv.length === 2;
 var filename;
 
-for (var i = 2; i < process.argv.length; ++i) {
+var i;
+for (i = 2; i < process.argv.length; ++i) {
   switch (process.argv[i]) {
     case "--help":
     case "-h":
@@ -36,19 +37,19 @@ if (show_help) {
   console.log("Usage: node parse.js [options] filename:");
   console.log("  -h [ --help ]                 Produce this help message");
   console.log("  filename                      The keysymdef.h file to parse");
-  return;
+  process.exit(0);
 }
 
 var buf = fs.readFileSync(filename);
 var str = buf.toString('utf8');
 
-var re = /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/m;
+var re = /^#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/m;
 
 var arr = str.split('\n');
 
 var codepoints = {};
 
-for (var i = 0; i < arr.length; ++i) {
+for (i = 0; i < arr.length; ++i) {
     var result = re.exec(arr[i]);
     if (result){
         var keyname = result[1];
@@ -84,7 +85,7 @@ function toHex(num) {
         s = ("0000" + s).slice(-4);
     }
     return "0x" + s;
-};
+}
 
 for (var codepoint in codepoints) {
     codepoint = parseInt(codepoint);
index 876f65250bd38c9d26c690c2f52f8906d204eabf..ab0cbcfba4e5042804d7f7ee8ed3d2d99d736fe8 100755 (executable)
@@ -100,7 +100,7 @@ var transform_html = function (legacy_scripts, only_legacy) {
         var start_ind = contents.indexOf(start_marker) + start_marker.length;
         var end_ind = contents.indexOf(end_marker, start_ind);
 
-        new_script = '';
+        var new_script = '';
 
         if (only_legacy) {
             // Only legacy version, so include things directly
@@ -161,11 +161,12 @@ var make_lib_files = function (import_format, source_maps, with_app_dir, only_le
     }
 
     var in_path;
+    var out_path_base;
     if (with_app_dir) {
-        var out_path_base = paths.out_dir_base;
+        out_path_base = paths.out_dir_base;
         in_path = paths.main;
     } else {
-        var out_path_base = paths.lib_dir_base;
+        out_path_base = paths.lib_dir_base;
     }
     const legacy_path_base = only_legacy ? out_path_base : path.join(out_path_base, 'legacy');
 
@@ -223,7 +224,7 @@ var make_lib_files = function (import_format, source_maps, with_app_dir, only_le
             return babelTransformFile(filename, opts)
             .then(res => {
                 console.log(`Writing ${legacy_path}`);
-                var {code, map, ast} = res;
+                var {code, map} = res;
                 if (source_maps === true) {
                     // append URL for external source map
                     code += `\n//# sourceMappingURL=${path.basename(legacy_path)}.map\n`;
index 19a43b7749a326ca202df7505afa79731d717335..9bba453912918d30df1683c876c38a37e11dfc42 100644 (file)
@@ -1,6 +1,5 @@
 // writes helpers require for vnc.html (they should output app.js)
 var fs = require('fs');
-var fse = require('fs-extra');
 var path = require('path');
 
 // util.promisify requires Node.js 8.x, so we have our own