From e768a633b751af716d2289b67d036baaf176eb17 Mon Sep 17 00:00:00 2001 From: Joshua Spence <josh@joshuaspence.com> Date: Wed, 14 Jan 2015 07:59:56 +1100 Subject: [PATCH] Fix various lint issues in rJX Summary: Ref T6953. Test Plan: `arc lint` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T6953 Differential Revision: https://secure.phabricator.com/D11376 --- .../externals/javelin/core/__tests__/stratcom.js | 6 +++--- .../externals/javelin/core/__tests__/util.js | 2 +- webroot/rsrc/externals/javelin/core/install.js | 2 +- webroot/rsrc/externals/javelin/core/util.js | 2 +- .../javelin/ext/reactor/core/Reactor.js | 2 +- .../javelin/ext/reactor/core/ReactorNode.js | 2 +- .../externals/javelin/ext/reactor/dom/RDOM.js | 6 +++--- .../rsrc/externals/javelin/ext/view/HTMLView.js | 16 ++++++++-------- .../javelin/ext/view/ViewInterpreter.js | 2 +- .../javelin/ext/view/ViewPlaceholder.js | 4 ++-- .../javelin/ext/view/__tests__/ViewRenderer.js | 4 ++-- webroot/rsrc/externals/javelin/lib/Leader.js | 3 +-- webroot/rsrc/externals/javelin/lib/Request.js | 8 ++++---- webroot/rsrc/externals/javelin/lib/Resource.js | 2 +- webroot/rsrc/externals/javelin/lib/WebSocket.js | 4 ++-- .../rsrc/externals/javelin/lib/__tests__/JSON.js | 2 +- .../rsrc/externals/javelin/lib/__tests__/URI.js | 2 +- .../javelin/lib/control/tokenizer/Tokenizer.js | 4 ---- .../javelin/lib/control/typeahead/Typeahead.js | 8 ++++---- .../control/typeahead/source/TypeaheadSource.js | 2 +- 20 files changed, 39 insertions(+), 44 deletions(-) diff --git a/webroot/rsrc/externals/javelin/core/__tests__/stratcom.js b/webroot/rsrc/externals/javelin/core/__tests__/stratcom.js index 6638ef1fc0..2bdbae8d78 100644 --- a/webroot/rsrc/externals/javelin/core/__tests__/stratcom.js +++ b/webroot/rsrc/externals/javelin/core/__tests__/stratcom.js @@ -3,10 +3,10 @@ * javelin-dom */ describe('Stratcom Tests', function() { - node1 = document.createElement('div'); + var node1 = document.createElement('div'); JX.Stratcom.addSigil(node1, 'what'); - node2 = document; - node3 = document.createElement('div'); + var node2 = document; + var node3 = document.createElement('div'); node3.className = 'what'; it('should disallow document', function() { diff --git a/webroot/rsrc/externals/javelin/core/__tests__/util.js b/webroot/rsrc/externals/javelin/core/__tests__/util.js index b2f72c6747..0f7f861a19 100644 --- a/webroot/rsrc/externals/javelin/core/__tests__/util.js +++ b/webroot/rsrc/externals/javelin/core/__tests__/util.js @@ -29,7 +29,7 @@ describe('JX.isArray', function() { it('should identify an array from another context as an array', function() { var iframe = document.createElement('iframe'); - var name = iframe.name = 'javelin-iframe-test'; + iframe.name = 'javelin-iframe-test'; iframe.style.display = 'none'; document.body.insertBefore(iframe, document.body.firstChild); diff --git a/webroot/rsrc/externals/javelin/core/install.js b/webroot/rsrc/externals/javelin/core/install.js index 284d529be4..c56e6489a0 100644 --- a/webroot/rsrc/externals/javelin/core/install.js +++ b/webroot/rsrc/externals/javelin/core/install.js @@ -236,7 +236,7 @@ JX.createClass = function(junk) { }; }; var getter = function(prop) { - return function(v) { + return function() { return this[prop]; }; }; diff --git a/webroot/rsrc/externals/javelin/core/util.js b/webroot/rsrc/externals/javelin/core/util.js index be43b73faa..e09171d0d6 100644 --- a/webroot/rsrc/externals/javelin/core/util.js +++ b/webroot/rsrc/externals/javelin/core/util.js @@ -283,7 +283,7 @@ if (!window.console || !window.console.log) { if (window.opera && window.opera.postError) { window.console = {log: function(m) { window.opera.postError(m); }}; } else { - window.console = {log: function(m) { }}; + window.console = {log: function() {}}; } } diff --git a/webroot/rsrc/externals/javelin/ext/reactor/core/Reactor.js b/webroot/rsrc/externals/javelin/ext/reactor/core/Reactor.js index a40d864dc8..3af21b14b5 100644 --- a/webroot/rsrc/externals/javelin/ext/reactor/core/Reactor.js +++ b/webroot/rsrc/externals/javelin/ext/reactor/core/Reactor.js @@ -38,7 +38,7 @@ JX.install('Reactor', { * For internal use by the Reactor system. */ _postOrder : function(node, result, pending) { - if (typeof result === "undefined") { + if (typeof result === 'undefined') { result = []; pending = {}; } diff --git a/webroot/rsrc/externals/javelin/ext/reactor/core/ReactorNode.js b/webroot/rsrc/externals/javelin/ext/reactor/core/ReactorNode.js index 02c60f9c41..c500ce4c33 100644 --- a/webroot/rsrc/externals/javelin/ext/reactor/core/ReactorNode.js +++ b/webroot/rsrc/externals/javelin/ext/reactor/core/ReactorNode.js @@ -57,7 +57,7 @@ JX.install('ReactorNode', { /** * For internal use by the Reactor system */ - getNextPulse : function(pulse) { + getNextPulse : function() { return this._nextPulse; }, getTransformer : function() { diff --git a/webroot/rsrc/externals/javelin/ext/reactor/dom/RDOM.js b/webroot/rsrc/externals/javelin/ext/reactor/dom/RDOM.js index f34907f27f..8bdbefd07b 100644 --- a/webroot/rsrc/externals/javelin/ext/reactor/dom/RDOM.js +++ b/webroot/rsrc/externals/javelin/ext/reactor/dom/RDOM.js @@ -121,7 +121,7 @@ JX.install('RDOM', { if (__DEV__) { if (!found) { - throw new Error("Mismatched radio button value"); + throw new Error('Mismatched radio button value'); } } }); @@ -163,7 +163,7 @@ JX.install('RDOM', { return rnode.transform(function(val) { if (__DEV__) { if (!(val === true || val === false)) { - throw new Error("Send boolean values to checkboxes."); + throw new Error('Send boolean values to checkboxes.'); } } @@ -255,7 +255,7 @@ JX.install('RDOM', { if (__DEV__) { if (select.value !== val) { - throw new Error("Mismatched select value"); + throw new Error('Mismatched select value'); } } }); diff --git a/webroot/rsrc/externals/javelin/ext/view/HTMLView.js b/webroot/rsrc/externals/javelin/ext/view/HTMLView.js index 244b252e05..c9eff564b8 100644 --- a/webroot/rsrc/externals/javelin/ext/view/HTMLView.js +++ b/webroot/rsrc/externals/javelin/ext/view/HTMLView.js @@ -26,10 +26,10 @@ JX.install('HTMLView', { return new JX.ViewVisitor(JX.HTMLView.validate); }, - validate: function(view, children) { + validate: function(view) { var spec = this._getHTMLSpec(); if (!(view.getName() in spec)) { - throw new Error("invalid tag"); + throw new Error('invalid tag'); } var tag_spec = spec[view.getName()]; @@ -37,11 +37,11 @@ JX.install('HTMLView', { var attrs = view.getAllAttributes(); for (var attr in attrs) { if (!(attr in tag_spec)) { - throw new Error("invalid attr"); + throw new Error('invalid attr'); } var validator = tag_spec[attr]; - if (typeof validator === "function") { + if (typeof validator === 'function') { return validator(attrs[attr]); } } @@ -51,10 +51,10 @@ JX.install('HTMLView', { _validateRel: function(target) { return target in { - "_blank": 1, - "_self": 1, - "_parent": 1, - "_top": 1 + '_blank': 1, + '_self': 1, + '_parent': 1, + '_top': 1 }; }, _getHTMLSpec: function() { diff --git a/webroot/rsrc/externals/javelin/ext/view/ViewInterpreter.js b/webroot/rsrc/externals/javelin/ext/view/ViewInterpreter.js index 743071e101..bb2a5b0bc7 100644 --- a/webroot/rsrc/externals/javelin/ext/view/ViewInterpreter.js +++ b/webroot/rsrc/externals/javelin/ext/view/ViewInterpreter.js @@ -56,7 +56,7 @@ JX.install('ViewInterpreter', { if (properties instanceof JX.View || properties instanceof JX.HTML || properties.nodeType || - typeof properties === "string") { + typeof properties === 'string') { children.unshift(properties); properties = {}; } diff --git a/webroot/rsrc/externals/javelin/ext/view/ViewPlaceholder.js b/webroot/rsrc/externals/javelin/ext/view/ViewPlaceholder.js index 7a2b79cfc2..6439e5c796 100644 --- a/webroot/rsrc/externals/javelin/ext/view/ViewPlaceholder.js +++ b/webroot/rsrc/externals/javelin/ext/view/ViewPlaceholder.js @@ -53,12 +53,12 @@ -JX.behavior('view-placeholder', function(config, statics) { +JX.behavior('view-placeholder', function(config) { JX.ViewPlaceholder.register(config.trigger_id, config.id, function() { var replace = JX.$(config.id); var children = config.children; - if (typeof children === "string") { + if (typeof children === 'string') { children = JX.$H(children); } diff --git a/webroot/rsrc/externals/javelin/ext/view/__tests__/ViewRenderer.js b/webroot/rsrc/externals/javelin/ext/view/__tests__/ViewRenderer.js index 1e8729e5c4..2247611f31 100644 --- a/webroot/rsrc/externals/javelin/ext/view/__tests__/ViewRenderer.js +++ b/webroot/rsrc/externals/javelin/ext/view/__tests__/ViewRenderer.js @@ -11,11 +11,11 @@ describe('JX.ViewRenderer', function() { var child = new JX.View({}); var parent = new JX.View({}); parent.addChild(child); - child.render = function(_) { + child.render = function() { child_rendered = true; }; - parent.render = function(rendered_children) { + parent.render = function() { child_rendered_first = child_rendered; }; diff --git a/webroot/rsrc/externals/javelin/lib/Leader.js b/webroot/rsrc/externals/javelin/lib/Leader.js index f259d79105..d6a7ebd5fa 100644 --- a/webroot/rsrc/externals/javelin/lib/Leader.js +++ b/webroot/rsrc/externals/javelin/lib/Leader.js @@ -219,7 +219,7 @@ JX.install('Leader', { _read: function() { var self = JX.Leader; - leader = window.localStorage.getItem(self._leaderKey) || '0:0'; + var leader = window.localStorage.getItem(self._leaderKey) || '0:0'; leader = leader.split(':'); return { @@ -305,4 +305,3 @@ JX.install('Leader', { } }); - diff --git a/webroot/rsrc/externals/javelin/lib/Request.js b/webroot/rsrc/externals/javelin/lib/Request.js index 14d13905d0..50e044b038 100644 --- a/webroot/rsrc/externals/javelin/lib/Request.js +++ b/webroot/rsrc/externals/javelin/lib/Request.js @@ -39,10 +39,10 @@ JX.install('Request', { try { return new XMLHttpRequest(); } catch (x) { - return new ActiveXObject("Msxml2.XMLHTTP"); + return new ActiveXObject('Msxml2.XMLHTTP'); } } catch (x) { - return new ActiveXObject("Microsoft.XMLHTTP"); + return new ActiveXObject('Microsoft.XMLHTTP'); } }, @@ -269,10 +269,10 @@ JX.install('Request', { try { if (typeof DOMParser != 'undefined') { var parser = new DOMParser(); - doc = parser.parseFromString(text, "text/xml"); + doc = parser.parseFromString(text, 'text/xml'); } else { // IE // an XDomainRequest - doc = new ActiveXObject("Microsoft.XMLDOM"); + doc = new ActiveXObject('Microsoft.XMLDOM'); doc.async = false; doc.loadXML(xport.responseText); } diff --git a/webroot/rsrc/externals/javelin/lib/Resource.js b/webroot/rsrc/externals/javelin/lib/Resource.js index c5133ab6a8..4e7d528740 100644 --- a/webroot/rsrc/externals/javelin/lib/Resource.js +++ b/webroot/rsrc/externals/javelin/lib/Resource.js @@ -25,7 +25,7 @@ JX.install('Resource', { */ load: function(list, callback) { var resources = {}, - uri, resource, path, type; + uri, resource, path; list = JX.$AX(list); diff --git a/webroot/rsrc/externals/javelin/lib/WebSocket.js b/webroot/rsrc/externals/javelin/lib/WebSocket.js index a7f5d1a864..8fd426f4bc 100644 --- a/webroot/rsrc/externals/javelin/lib/WebSocket.js +++ b/webroot/rsrc/externals/javelin/lib/WebSocket.js @@ -107,7 +107,7 @@ JX.install('WebSocket', { /** * Callback for connection open. */ - _onopen: function(e) { + _onopen: function() { this._isOpen = true; // Reset the reconnect delay, since we connected successfully. @@ -144,7 +144,7 @@ JX.install('WebSocket', { /** * Callback for connection close. */ - _onclose: function(e) { + _onclose: function() { this._isOpen = false; var done = false; diff --git a/webroot/rsrc/externals/javelin/lib/__tests__/JSON.js b/webroot/rsrc/externals/javelin/lib/__tests__/JSON.js index 539a41610e..05b236307d 100644 --- a/webroot/rsrc/externals/javelin/lib/__tests__/JSON.js +++ b/webroot/rsrc/externals/javelin/lib/__tests__/JSON.js @@ -7,7 +7,7 @@ describe('JSON', function() { it('should encode and decode an object', function() { var object = { a: [0, 1, 2], - s: "Javelin Stuffs", + s: 'Javelin Stuffs', u: '\x01', n: 1, f: 3.14, diff --git a/webroot/rsrc/externals/javelin/lib/__tests__/URI.js b/webroot/rsrc/externals/javelin/lib/__tests__/URI.js index a162ad59b8..382ba3ca7e 100644 --- a/webroot/rsrc/externals/javelin/lib/__tests__/URI.js +++ b/webroot/rsrc/externals/javelin/lib/__tests__/URI.js @@ -43,7 +43,7 @@ describe('Javelin URI', function() { }); function charRange(from, to) { - res = ''; + var res = ''; for (var i = from.charCodeAt(0); i <= to.charCodeAt(0); i++) { res += String.fromCharCode(i); } diff --git a/webroot/rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js b/webroot/rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js index dc516f3de5..fd5aae35d8 100644 --- a/webroot/rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js +++ b/webroot/rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js @@ -250,7 +250,6 @@ JX.install('Tokenizer', { } this._lastvalue = focus.value; - var root = this._root; var metrics = JX.DOM.textMetrics( this._focus, 'jx-tokenizer-metrics'); @@ -353,9 +352,6 @@ JX.install('Tokenizer', { }, _onkeydown : function(e) { - var focus = this._focus; - var root = this._root; - var raw = e.getRawEvent(); if (raw.ctrlKey || raw.metaKey || raw.altKey) { return; diff --git a/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js b/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js index d8f8aa27bf..5875bf9ea6 100644 --- a/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js +++ b/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js @@ -137,9 +137,9 @@ JX.install('Typeahead', { if (__DEV__) { if (!this._datasource) { throw new Error( - "JX.Typeahead.start(): " + - "No datasource configured. Create a datasource and call " + - "setDatasource()."); + 'JX.Typeahead.start(): ' + + 'No datasource configured. Create a datasource and call ' + + 'setDatasource().'); } } this.updatePlaceholder(); @@ -402,7 +402,7 @@ JX.install('Typeahead', { this._choose(this._display[this._focus]); return true; } else { - result = this.invoke('query', this._control.value); + var result = this.invoke('query', this._control.value); if (result.getPrevented()) { return true; } diff --git a/webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js b/webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js index 3ce355a2e0..31b9866d46 100644 --- a/webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js +++ b/webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js @@ -147,7 +147,7 @@ JX.install('TypeaheadSource', { this._startListener.remove(); }, - didChange : function(value) { + didChange : function() { return; },