Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1341029 - Turn on the ESLint no-undef rule for all of toolkit/. r…
Browse files Browse the repository at this point in the history
…=jaws

MozReview-Commit-ID: Ed9FfkskDos
  • Loading branch information
Standard8 committed Feb 20, 2017
1 parent 19904b0 commit ed7c2d5
Show file tree
Hide file tree
Showing 52 changed files with 156 additions and 59 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ toolkit/components/osfile/**

# External code:
toolkit/components/microformats/test/**
toolkit/components/microformats/microformat-shiv.js
toolkit/components/reader/Readability.js
toolkit/components/reader/JSDOMParser.js

Expand Down
3 changes: 3 additions & 0 deletions testing/mochitest/chrome.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ module.exports = {
"addLoadEvent": false,
"Assert": false,
"BrowserTestUtils": false,
"ContentTask": false,
"EventUtils": false,
"executeSoon": false,
"export_assertions": false,
"extractJarToTmp": false,
"finish": false,
"getJar": false,
"getRootDirectory": false,
"getTestFilePath": false,
"gTestPath": false,
Expand Down
4 changes: 4 additions & 0 deletions toolkit/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ module.exports = {
"ChromeUtils": false,
"Components": false,
"dump": true,
// Specific to Firefox
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
"InternalError": true,
"KeyEvent": false,
"openDialog": false,
"MenuBoxObject": false,
"SimpleGestureEvent": false,
"sizeToContent": false,
"SharedArrayBuffer": false,
// Note: StopIteration will likely be removed as part of removing legacy
Expand Down
7 changes: 0 additions & 7 deletions toolkit/components/.eslintrc.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Global in the DOM for privileged code only.
/* global CheckerboardReportService */

"use strict";

var trace;
Expand Down
7 changes: 7 additions & 0 deletions toolkit/components/aboutmemory/tests/xpcshell/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"../../../../../testing/xpcshell/xpcshell.eslintrc.js"
]
};
2 changes: 2 additions & 0 deletions toolkit/components/addoncompat/tests/addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ function testAboutModuleRegistration() {
*/
let testAboutModulesWork = (browser) => {
let testConnection = () => {
// This section is loaded into a frame script.
/* global content:false */
let request = new content.XMLHttpRequest();
try {
request.open("GET", "about:test1", false);
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/alerts/test/test_image.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
var [ready] = yield promiseImage(alert, 1000);
ok(!ready, "Should cancel request if timeout fires");

[ready, request] = yield promiseImage(alert, 45000);
[ready] = yield promiseImage(alert, 45000);
ok(ready, "Should load image if request finishes before timeout");
});

Expand Down
3 changes: 3 additions & 0 deletions toolkit/components/exthelper/extApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// This file expects these globals to be declared before it is included.
/* global Ci, Cc */

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Services.scriptloader.loadSubScript(sharedUrl, this);
// Define output functions so they look the same across all frameworks. Since
// we don't have an output function available here, we report as TEST-PASS.
var Output = {
print: message => assert.ok(true, message),
print: message => assert.ok(false, message),
};

// Define assertion functions so they look the same across all frameworks.
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/gfx/content/gfxFrameScript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env mozilla/frame-script */

var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

const gfxFrameScript = {
domUtils: null,
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/lz4/lz4_internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if (typeof Components != "undefined") {
this.Primitives = Primitives;
this.exports = {};
} else if (typeof module != "undefined" && typeof require != "undefined") {
/* global require:false */
SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
} else {
throw new Error("Please load this module with Component.utils.import or with require()");
Expand Down Expand Up @@ -56,6 +57,7 @@ libxul.declareLazyFFI(Primitives, "maxCompressedSize",
);

if (typeof module != "undefined") {
/* global module:false */
module.exports = {
get compress() {
return Primitives.compress;
Expand Down
8 changes: 8 additions & 0 deletions toolkit/components/microformats/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

module.exports = {
"env": {
"node": true,
"amd": true,
}
};
4 changes: 2 additions & 2 deletions toolkit/components/microformats/update/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

// configuration
var deployDir = "../"
exportedSymbol = 'try {\n // mozilla jsm support\n Components.utils.importGlobalProperties(["URL"]);\n} catch(e) {}\nthis.EXPORTED_SYMBOLS = [\'Microformats\'];';
var deployDir = "../";
var exportedSymbol = 'try {\n // mozilla jsm support\n Components.utils.importGlobalProperties(["URL"]);\n} catch(e) {}\nthis.EXPORTED_SYMBOLS = [\'Microformats\'];';



Expand Down
7 changes: 7 additions & 0 deletions toolkit/components/mozprotocol/tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"../../../../testing/mochitest/chrome.eslintrc.js"
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ add_task(function* test_open_window_then_watch_it() {
}

info(`Attempting to remove a performance listener incorrectly, check that this does not hurt our real listener`);
Assert.throws(() => PerformanceWatcher.removePerformanceListener({addonId: addon.addonId}, () => {}));
Assert.throws(() => PerformanceWatcher.removePerformanceListener({addonId: addon.addonId + "-unbound-id-" + Math.random()}, realListener.listener));
Assert.throws(() => PerformanceWatcher.removePerformanceListener({windowId: burner.windowId}, () => {}),
/No listener for target/, "should throw an error for a different listener");
Assert.throws(() => PerformanceWatcher.removePerformanceListener({windowId: burner.windowId + "-unbound-id-" + Math.random()}, realListener.listener),
/No listener for target/, "should throw an error for a different window id");

// Waiting a little – listeners are buffered.
yield new Promise(resolve => setTimeout(resolve, 100));
Expand Down
3 changes: 3 additions & 0 deletions toolkit/components/printing/content/printUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is loaded into the browser window scope.
/* eslint mozilla/import-browserjs-globals:"warn" */

// -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*-

/* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
7 changes: 7 additions & 0 deletions toolkit/components/printing/tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"../../../../testing/mochitest/chrome.eslintrc.js"
],
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file spawns content tasks.
/* global content */

/**
* Verify that if the page contents change after print preview is initialized,
* and we re-initialize print preview (e.g. by changing page orientation),
Expand Down
3 changes: 3 additions & 0 deletions toolkit/components/prompts/content/selectDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Defined in dialog.xml.
/* globals centerWindowOnScreen:false, moveToAlertPosition:false */

var Ci = Components.interfaces;
var Cr = Components.results;
var Cc = Components.classes;
Expand Down
4 changes: 4 additions & 0 deletions toolkit/components/prompts/content/tabprompts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!-- This file is imported into the browser window, and expects various variables,
e.g. Ci, Services, to be available. -->
<!-- eslint mozilla/import-browserjs-globals:"warn" -->

<!DOCTYPE bindings [
<!ENTITY % commonDialogDTD SYSTEM "chrome://global/locale/commonDialog.dtd">
<!ENTITY % dialogOverlayDTD SYSTEM "chrome://global/locale/dialogOverlay.dtd">
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/satchel/test/parent_utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-env mozilla/frame-script */
// assert is available to chrome scripts loaded via SpecialPowers.loadChromeScript.
/* global assert */

const { classes: Cc, interfaces: Ci, utils: Cu } = Components;

Expand Down
6 changes: 6 additions & 0 deletions toolkit/components/viewsource/content/viewSource.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-

/* import-globals-from ../../../content/globalOverlay.js */
/* import-globals-from ../../printing/content/printUtils.js */
/* import-globals-from ../../../content/viewZoomOverlay.js */
/* import-globals-from ../../../content/contentAreaUtils.js */

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Expand All @@ -16,6 +21,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");

/* global gBrowser, gViewSourceBundle, gContextMenu */
[
["gBrowser", "content"],
["gViewSourceBundle", "viewSourceBundle"],
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/windowcreator/test/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module.exports = { // eslint-disable-line no-undef
"extends": [
"../../../../testing/mochitest/browser.eslintrc.js",
"../../../../testing/mochitest/chrome.eslintrc.js",
"../../../../testing/mochitest/mochitest.eslintrc.js",
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ add_task(function* test_new_remote_window_flags() {
// as part of the TabChild, so we have to check those too.
let b = win.gBrowser.selectedBrowser;
let contentChromeFlags = yield ContentTask.spawn(b, null, function*() {
// Content scripts provide docShell as a global.
/* global docShell */
docShell.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// This will throw if we're not a remote browser.
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module.exports = {
"rules": {
"no-undef": "off"
"mozilla/import-browserjs-globals": "warn",
}
};
2 changes: 1 addition & 1 deletion toolkit/content/aboutSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ var snapshotFormatters = {
if (crashGuards.length) {
for (let guard of crashGuards) {
let resetButton = $.new("button");
onClickReset = function() {
let onClickReset = function() {
Services.prefs.setIntPref(guard.prefName, 0);
resetButton.removeEventListener("click", onClickReset);
resetButton.disabled = true;
Expand Down
3 changes: 2 additions & 1 deletion toolkit/content/datepicker.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</div>
</template>
<script type="application/javascript">
/* import-globals-from widgets/datepicker.js */
// We need to hide the scroll bar but maintain its scrolling
// capability, so using |overflow: hidden| is not an option.
// Instead, we are inserting a user agent stylesheet that is
Expand All @@ -57,4 +58,4 @@
});
</script>
</body>
</html>
</html>
3 changes: 3 additions & 0 deletions toolkit/content/finddialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Defined in dialog.xml.
/* globals moveToAlertPosition */

Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/FormHistory.jsm");

Expand Down
4 changes: 2 additions & 2 deletions toolkit/content/macWindowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function macWindowMenuDidShow() {

function toOpenWindow( aWindow ) {
// deminiaturize the window, if it's in the Dock
if (aWindow.windowState == STATE_MINIMIZED)
if (aWindow.windowState == window.STATE_MINIMIZED)
aWindow.restore();
aWindow.document.commandDispatcher.focusedWindow.focus();
}
Expand All @@ -40,7 +40,7 @@ function ShowWindowFromResource( node ) {
}

function zoomWindow() {
if (window.windowState == STATE_NORMAL)
if (window.windowState == window.STATE_NORMAL)
window.maximize();
else
window.restore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function check_audio_onplay() {
var audio = list[0];
return new Promise((resolve, reject) => {
audio.onplay = () => {
ok(needToReceiveOnPlay, "Should not receive play event!");
ok(false, "Should not receive play event!");
this.onplay = null;
reject();
};
Expand Down
2 changes: 2 additions & 0 deletions toolkit/content/tests/browser/browser_saveImageURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const IMAGE_PAGE = "https://example.com/browser/toolkit/content/tests/browser/image_page.html";
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";

var MockFilePicker = SpecialPowers.MockFilePicker;

MockFilePicker.init(window);
MockFilePicker.returnValue = MockFilePicker.returnCancel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function test() {
}
}

/* import-globals-from common/mockTransfer.js */
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
Expand Down
4 changes: 2 additions & 2 deletions toolkit/content/tests/chrome/RegisterUnregisterChrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var gPrefs = Cc["@mozilla.org/preferences-service;1"].
// we know the mochitest harness kills off the profile when it's done.
function copyToTemporaryFile(f) {
let tmpd = gDirSvc.get("ProfD", Ci.nsIFile);
tmpf = tmpd.clone();
let tmpf = tmpd.clone();
tmpf.append("temp.manifest");
tmpf.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
tmpf.remove(false);
Expand Down Expand Up @@ -68,7 +68,7 @@ function copyDirToTempProfile(path, subdirname) {

// The SimpleTest directory is hidden
var files = Array.from(dirIter("file://" + rootDir));
for (f in files) {
for (let f in files) {
files[f].copyTo(tmpdir, "");
}
return tmpdir;
Expand Down
2 changes: 2 additions & 0 deletions toolkit/content/tests/chrome/popup_trigger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* import-globals-from ../widgets/popup_shared.js */

var gMenuPopup = null;
var gTrigger = null;
var gIsMenu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<pre id="test">
<script class="testbody" type="text/javascript">
/* import-globals-from file_autocomplete_with_composition.js */

SimpleTest.waitForExplicitFinish();

Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/tests/widgets/test_videocontrols.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
// it's timing depending if the <scale> things it's click-and-hold, or a
// single click. So, just make sure we end up less that the previous
// position.
lastPosition = (videoDuration / 2) - 0.1;
var lastPosition = (videoDuration / 2) - 0.1;
ok(video.currentTime < lastPosition, "checking expected playback position");

// Set volume to 0.1 so one down arrow hit will decrease it to 0.
Expand Down
6 changes: 6 additions & 0 deletions toolkit/content/tests/widgets/tree_shared.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// This file expects the following globals to be defined at various times.
/* globals getCustomTreeViewCellInfo */

// This files relies on these specific Chrome/XBL globals
/* globals TreeColumns, TreeColumn */

var columns_simpletree =
[
{ name: "name", label: "Name", key: true, properties: "one two" },
Expand Down
3 changes: 3 additions & 0 deletions toolkit/content/tests/widgets/videocontrols_direction_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file expects `tests` to have been declared in the global scope.
/* global tests */

var RemoteCanvas = function(url, id) {
this.url = url;
this.id = id;
Expand Down
Loading

0 comments on commit ed7c2d5

Please sign in to comment.