Skip to content

Commit a47a3a0

Browse files
authored
ESLint: enable no-unused-vars on js files (#128)
Disabled on many lines to avoid potentially side effects in removing the variable.
1 parent 034b71b commit a47a3a0

File tree

83 files changed

+102
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+102
-235
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
"no-shadow-restricted-names": "error",
6464
"no-shadow": "warn",
6565
"no-undef": "error",
66-
"no-unused-vars": ["warn", {"vars": "all", "args": "none"}],
66+
"no-unused-vars": ["error", {"vars": "all", "args": "none"}],
6767
"no-use-before-define": "off",
6868
// http://eslint.org/docs/rules/#nodejs-and-commonjs
6969
"no-new-require": "error",
@@ -174,6 +174,9 @@ module.exports = {
174174
{
175175
"files": [
176176
"test/**",
177+
"src/extensions/default/**/unittests.js",
178+
"src/extensions/default/**/unittests.disabled.js",
179+
"src/extensibility/node/spec/*.js"
177180
],
178181
"env": {
179182
"jasmine": true,

src/LiveDevelopment/Agents/RemoteFunctions.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
/*jslint forin: true */
2626
/*global Node, MessageEvent */
2727
/*theseus instrument: false */
28+
/*exported RemoteFunctions*/
2829

2930
/**
3031
* RemoteFunctions define the functions to be executed in the browser. This
@@ -384,8 +385,6 @@ function RemoteFunctions(config, remoteWSPort) {
384385
}
385386
};
386387

387-
var mainBoxStyles = config.remoteHighlight.stylesToSet;
388-
389388
var paddingVisualisations = [
390389
drawPaddingRect("top"),
391390
drawPaddingRect("right"),
@@ -431,8 +430,6 @@ function RemoteFunctions(config, remoteWSPort) {
431430

432431
highlight.className = HIGHLIGHT_CLASSNAME;
433432

434-
var offset = _screenOffset(element);
435-
436433
var el = element,
437434
offsetLeft = 0,
438435
offsetTop = 0;
@@ -557,6 +554,7 @@ function RemoteFunctions(config, remoteWSPort) {
557554
}
558555
};
559556

557+
// eslint-disable-next-line no-unused-vars
560558
var _currentEditor;
561559
function _toggleEditor(element) {
562560
_currentEditor = new Editor(element);
@@ -1031,9 +1029,7 @@ function RemoteFunctions(config, remoteWSPort) {
10311029
var _ws = null;
10321030

10331031
function onDocumentClick(event) {
1034-
var element = event.target,
1035-
currentDataId,
1036-
newDataId;
1032+
var element = event.target;
10371033

10381034
if (_ws && element && element.hasAttribute("data-brackets-id")) {
10391035
_ws.send(JSON.stringify({

src/LiveDevelopment/LiveDevelopment.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*
2323
*/
2424

25-
/*global open */
26-
2725
/**
2826
* LiveDevelopment manages the Inspector, all Agents, and the active LiveDocument
2927
*

src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,11 @@ define(function (require, exports, module) {
267267
*/
268268
Builder.prototype.build = function (strict, markCache) {
269269
var self = this;
270-
var token, lastClosedTag, lastTextNode, lastIndex = 0;
270+
var token,
271+
lastClosedTag,
272+
lastTextNode,
273+
// eslint-disable-next-line no-unused-vars
274+
lastIndex = 0;
271275
var stack = this.stack;
272276
var attributeName = null;
273277
var nodeMap = {};

src/LiveDevelopment/MultiBrowserImpl/launchers/node/LauncherDomain.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var open = require("opn");
3333
* The Brackets domain manager for registering node extensions.
3434
* @type {?DomainManager}
3535
*/
36+
// eslint-disable-next-line no-unused-vars
3637
var _domainManager;
3738

3839
/**

src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*
2323
*/
2424

25-
/*global setInterval, clearInterval */
26-
2725
(function (global) {
2826
"use strict";
2927

@@ -139,12 +137,12 @@
139137
// http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events
140138
//
141139
// TODO: This is just a temporary 'cross-browser' solution, it needs optimization.
142-
var loadInterval = setInterval(function () {
140+
var loadInterval = window.setInterval(function () {
143141
var i;
144142
for (i = 0; i < window.document.styleSheets.length; i++) {
145143
if (window.document.styleSheets[i].href === href) {
146144
//clear interval
147-
clearInterval(loadInterval);
145+
window.clearInterval(loadInterval);
148146
// notify stylesheets added
149147
self.notifyStylesheetAdded(href);
150148
break;

src/brackets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ define(function (require, exports, module) {
7676
DefaultDialogs = require("widgets/DefaultDialogs"),
7777
ExtensionLoader = require("utils/ExtensionLoader"),
7878
Async = require("utils/Async"),
79+
// eslint-disable-next-line no-unused-vars
7980
UpdateNotification = require("utils/UpdateNotification"),
8081
UrlParams = require("utils/UrlParams").UrlParams,
8182
PreferencesManager = require("preferences/PreferencesManager"),

src/editor/CodeHintManager.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ define(function (require, exports, module) {
247247
hintList = null,
248248
deferredHints = null,
249249
keyDownEditor = null,
250-
codeHintsEnabled = true,
251-
codeHintOpened = false;
250+
codeHintsEnabled = true;
252251

253252

254253
PreferencesManager.definePreference("showCodeHints", "boolean", true, {
@@ -378,7 +377,6 @@ define(function (require, exports, module) {
378377
}
379378
hintList.close();
380379
hintList = null;
381-
codeHintOpened = false;
382380
keyDownEditor = null;
383381
sessionProvider = null;
384382
sessionEditor = null;

src/editor/Editor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,6 @@ define(function (require, exports, module) {
25492549
* @param {string} name The name of the gutter to be unregistered.
25502550
*/
25512551
Editor.unregisterGutter = function (name) {
2552-
var i, gutter;
25532552
registeredGutters = registeredGutters.filter(function (gutter) {
25542553
return gutter.name !== name;
25552554
});

src/extensibility/node/spec/Installation.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
/*eslint-env node */
2626
/*jslint node: true */
27-
/*global expect, describe, it, beforeEach, afterEach */
2827

2928
"use strict";
3029

src/extensibility/node/spec/Validation.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
/*eslint-env node */
2626
/*jslint node: true */
27-
/*global expect, describe, it, afterEach */
2827

2928
"use strict";
3029

src/extensions/default/CSSAtRuleCodeHints/unittests.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*
2323
*/
2424

25-
/*global describe, it, xit, expect, beforeEach, afterEach */
26-
2725
define(function (require, exports, module) {
2826
"use strict";
2927

@@ -39,24 +37,6 @@ define(function (require, exports, module) {
3937

4038
var testDocument, testEditor;
4139

42-
/*
43-
* Create a mockup editor with the given content and language id.
44-
*
45-
* @param {string} content - content for test window
46-
* @param {string} languageId
47-
*/
48-
function setupTest(content, languageId) {
49-
var mock = SpecRunnerUtils.createMockEditor(content, languageId);
50-
testDocument = mock.doc;
51-
testEditor = mock.editor;
52-
}
53-
54-
function tearDownTest() {
55-
SpecRunnerUtils.destroyMockEditor(testDocument);
56-
testEditor = null;
57-
testDocument = null;
58-
}
59-
6040
// Ask provider for hints at current cursor position; expect it to return some
6141
function expectHints(provider, implicitChar, returnWholeObj) {
6242
expect(provider.hasHints(testEditor, implicitChar)).toBe(true);
@@ -66,11 +46,6 @@ define(function (require, exports, module) {
6646
return returnWholeObj ? hintsObj : hintsObj.hints;
6747
}
6848

69-
// Ask provider for hints at current cursor position; expect it NOT to return any
70-
function expectNoHints(provider, implicitChar) {
71-
expect(provider.hasHints(testEditor, implicitChar)).toBe(false);
72-
}
73-
7449
// compares lists to ensure they are the same
7550
function verifyListsAreIdentical(hintList, values) {
7651
var i;
@@ -104,14 +79,6 @@ define(function (require, exports, module) {
10479
expect(hintList[0]).toBe(expectedFirstHint);
10580
}
10681

107-
// Helper function to
108-
// a) ensure the hintList and the list with the available values have the same size
109-
// b) ensure that all possible values are mentioned in the hintList
110-
function verifyAllValues(hintList, values) {
111-
expect(hintList.length).toBe(values.length);
112-
expect(hintList.sort().toString()).toBe(values.sort().toString());
113-
}
114-
11582
var modesToTest = ["css", "scss", "less"],
11683
modeCounter;
11784

src/extensions/default/CSSCodeHints/unittests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*
2323
*/
2424

25-
/*global describe, it, xit, expect, beforeEach, afterEach */
26-
2725
define(function (require, exports, module) {
2826
"use strict";
2927

src/extensions/default/CSSPseudoSelectorHints/unittests.js

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*
2323
*/
2424

25-
/*global describe, it, xit, expect, beforeEach, afterEach */
26-
2725
define(function (require, exports, module) {
2826
"use strict";
2927

@@ -45,24 +43,6 @@ define(function (require, exports, module) {
4543

4644
var testDocument, testEditor;
4745

48-
/*
49-
* Create a mockup editor with the given content and language id.
50-
*
51-
* @param {string} content - content for test window
52-
* @param {string} languageId
53-
*/
54-
function setupTest(content, languageId) {
55-
var mock = SpecRunnerUtils.createMockEditor(content, languageId);
56-
testDocument = mock.doc;
57-
testEditor = mock.editor;
58-
}
59-
60-
function tearDownTest() {
61-
SpecRunnerUtils.destroyMockEditor(testDocument);
62-
testEditor = null;
63-
testDocument = null;
64-
}
65-
6646
// Ask provider for hints at current cursor position; expect it to return some
6747
function expectHints(provider, implicitChar, returnWholeObj) {
6848
expect(provider.hasHints(testEditor, implicitChar)).toBe(true);
@@ -72,11 +52,6 @@ define(function (require, exports, module) {
7252
return returnWholeObj ? hintsObj : hintsObj.hints;
7353
}
7454

75-
// Ask provider for hints at current cursor position; expect it NOT to return any
76-
function expectNoHints(provider, implicitChar) {
77-
expect(provider.hasHints(testEditor, implicitChar)).toBe(false);
78-
}
79-
8055
// compares lists to ensure they are the same
8156
function verifyListsAreIdentical(hintList, values) {
8257
var i;
@@ -86,38 +61,10 @@ define(function (require, exports, module) {
8661
}
8762
}
8863

89-
90-
function selectHint(provider, expectedHint, implicitChar) {
91-
var hintList = expectHints(provider, implicitChar);
92-
expect(hintList.indexOf(expectedHint)).not.toBe(-1);
93-
return provider.insertHint(expectedHint);
94-
}
95-
96-
// Helper function for testing cursor position
97-
function fixPos(pos) {
98-
if (!("sticky" in pos)) {
99-
pos.sticky = null;
100-
}
101-
return pos;
102-
}
103-
function expectCursorAt(pos) {
104-
var selection = testEditor.getSelection();
105-
expect(fixPos(selection.start)).toEqual(fixPos(selection.end));
106-
expect(fixPos(selection.start)).toEqual(fixPos(pos));
107-
}
108-
10964
function verifyFirstEntry(hintList, expectedFirstHint) {
11065
expect(hintList[0]).toBe(expectedFirstHint);
11166
}
11267

113-
// Helper function to
114-
// a) ensure the hintList and the list with the available values have the same size
115-
// b) ensure that all possible values are mentioned in the hintList
116-
function verifyAllValues(hintList, values) {
117-
expect(hintList.length).toBe(values.length);
118-
expect(hintList.sort().toString()).toBe(values.sort().toString());
119-
}
120-
12168
var modesToTest = ["css", "scss", "less"],
12269
modeCounter;
12370

src/extensions/default/CloseOthers/unittests.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
*
2323
*/
2424

25-
/*global describe, it, expect, beforeEach, afterEach, runs, waitsForDone, spyOn */
26-
2725
define(function (require, exports, module) {
2826
"use strict";
2927

3028
var SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"),
3129
FileUtils = brackets.getModule("file/FileUtils"),
3230
CommandManager,
3331
Commands,
32+
// eslint-disable-next-line no-unused-vars
3433
Dialogs,
34+
// eslint-disable-next-line no-unused-vars
3535
EditorManager,
3636
DocumentManager,
3737
MainViewManager,
@@ -41,9 +41,11 @@ define(function (require, exports, module) {
4141
var extensionPath = FileUtils.getNativeModuleDirectoryPath(module),
4242
testPath = extensionPath + "/unittest-files/",
4343
testWindow,
44+
// eslint-disable-next-line no-unused-vars
4445
$,
4546
docSelectIndex,
4647
cmdToRun,
48+
// eslint-disable-next-line no-unused-vars
4749
brackets;
4850

4951
function createUntitled(count) {

src/extensions/default/CodeFolding/foldhelpers/foldgutter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ define(function (require, exports, module) {
341341
* @param {!Object} to the ch and line position that designates the end of the region
342342
*/
343343
function onFold(cm, from, to) {
344+
// eslint-disable-next-line no-unused-vars
344345
var state = cm.state.foldGutter;
345346
updateFoldInfo(cm, from.line, from.line + 1);
346347
}
@@ -352,6 +353,7 @@ define(function (require, exports, module) {
352353
* @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region
353354
*/
354355
function onUnFold(cm, from, to) {
356+
// eslint-disable-next-line no-unused-vars
355357
var state = cm.state.foldGutter;
356358
var vp = cm.getViewport();
357359
delete cm._lineFolds[from.line];

src/extensions/default/CodeFolding/foldhelpers/handlebarsFold.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
define(function (require, exports, module) {
3232
"use strict";
33-
var CodeMirror = brackets.getModule("thirdparty/CodeMirror/lib/codemirror"),
34-
_ = brackets.getModule("thirdparty/lodash"),
33+
34+
var _ = brackets.getModule("thirdparty/lodash"),
3535
StringUtils = brackets.getModule("utils/StringUtils");
3636

3737
/**

src/extensions/default/CodeFolding/unittests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* @date 01/08/2015 18:34
55
*/
66

7-
/*global describe, xdescribe, beforeEach, afterEach, it, expect, runs, waitsForDone, waitsFor*/
8-
97
define(function (require, exports, module) {
108
"use strict";
119
var SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"),
@@ -24,6 +22,7 @@ define(function (require, exports, module) {
2422
var testWindow,
2523
testEditor,
2624
EditorManager,
25+
// eslint-disable-next-line no-unused-vars
2726
DocumentManager,
2827
CommandManager,
2928
PreferencesManager,

0 commit comments

Comments
 (0)