diff --git a/.eslintrc-rollouts.js b/.eslintrc-rollouts.js index b0e41056e886..68460242d191 100644 --- a/.eslintrc-rollouts.js +++ b/.eslintrc-rollouts.js @@ -1992,6 +1992,7 @@ const rollouts = [ // TODO: Bug TBD - Finish enabling no-shadow with builtinGlobals: true // for system modules. files: [ + "browser/components/extensions/Extension*.sys.mjs", "docshell/base/URIFixup.sys.mjs", "dom/base/ContentAreaDropListener.sys.mjs", "dom/manifest/ImageObjectProcessor.sys.mjs", @@ -2028,6 +2029,54 @@ const rollouts = [ "no-shadow": ["warn", { allow: ["event"], builtinGlobals: true }], }, }, + { + files: [ + "browser/components/extensions/**", + "docshell/test/**", + "devtools/client/framework/**", + "dom/fetch/tests/**", + "dom/indexedDB/test/**", + "dom/media/**", + "dom/notification/test/browser/browser_permission_dismiss.js", + "dom/security/**", + "dom/tests/browser/**", + "dom/xslt/tests/browser/file_bug1309630.html", + "extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xhtml", + "gfx/layers/layerviewer/layerTreeView.js", + "image/test/browser/browser_animated_css_image.js", + "js/src/builtin/Promise.js", + "js/xpconnect/tests/**", + "layout/tools/reftest/reftest-content.js", + "mobile/android/geckoview/**", + "mobile/shared/components/extensions/**", + "netwerk/**", + "remote/cdp/**", + "remote/shared/**", + "remote/webdriver-bidi/**", + "security/manager/**", + "security/sandbox/**", + "taskcluster/docker/periodic-updates/scripts/genHPKPStaticPins.js", + "testing/condprofile/condprof/scenarii/bookmark.js", + "testing/**", + "toolkit/components/**", + "toolkit/content/**", + "toolkit/crashreporter/**", + "toolkit/modules/subprocess/subprocess_shared.js", + "toolkit/modules/tests/**", + "toolkit/mozapps/**", + "toolkit/themes/shared/design-system/tests/try-runner.js", + "tools/profiler/tests/**", + "tools/tryselect/selectors/chooser/static/filter.js", + ], + excludedFiles: [ + "**/*.sys.mjs", + "toolkit/components/narrate/**", + "toolkit/components/reader/**", + ], + rules: { + "no-shadow": "off", + }, + }, ]; module.exports = { rollouts }; diff --git a/.eslintrc.js b/.eslintrc.js index f43504477d6a..0d3fdc7dd64e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -29,9 +29,9 @@ function removeOverrides(config) { return config; } -function readFile(path) { +function readFile(filePath) { return fs - .readFileSync(path, { encoding: "utf-8" }) + .readFileSync(filePath, { encoding: "utf-8" }) .split("\n") .filter(p => p && !p.startsWith("#")); } @@ -154,7 +154,7 @@ module.exports = { }, { ...removeOverrides(xpcshellTestConfig), - files: testPaths.xpcshell.map(path => `${path}**`), + files: testPaths.xpcshell.map(filePath => `${filePath}**`), excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], }, { @@ -162,7 +162,7 @@ module.exports = { // would require searching the other test files to know if they are used or not. // This would be expensive and slow, and it isn't worth it for head files. // We could get developers to declare as exported, but that doesn't seem worth it. - files: testPaths.xpcshell.map(path => `${path}head*.js`), + files: testPaths.xpcshell.map(filePath => `${filePath}head*.js`), rules: { "no-unused-vars": [ "error", @@ -179,7 +179,7 @@ module.exports = { // This is not done in the xpcshell-test configuration as we cannot pull // in overrides from there. We should at some stage, aim to enable this // for all files in xpcshell-tests. - files: testPaths.xpcshell.map(path => `${path}test*.js`), + files: testPaths.xpcshell.map(filePath => `${filePath}test*.js`), rules: { // No declaring variables that are never used "no-unused-vars": [ @@ -193,12 +193,12 @@ module.exports = { }, { ...removeOverrides(browserTestConfig), - files: testPaths.browser.map(path => `${path}**`), + files: testPaths.browser.map(filePath => `${filePath}**`), excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], }, { ...removeOverrides(mochitestTestConfig), - files: testPaths.mochitest.map(path => `${path}**`), + files: testPaths.mochitest.map(filePath => `${filePath}**`), excludedFiles: [ "**/*.jsm", "**/*.mjs", @@ -207,7 +207,7 @@ module.exports = { }, { ...removeOverrides(chromeTestConfig), - files: testPaths.chrome.map(path => `${path}**`), + files: testPaths.chrome.map(filePath => `${filePath}**`), excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], }, { @@ -218,8 +218,8 @@ module.exports = { "mozilla/simpletest": true, }, files: [ - ...testPaths.mochitest.map(path => `${path}/**/*.js`), - ...testPaths.chrome.map(path => `${path}/**/*.js`), + ...testPaths.mochitest.map(filePath => `${filePath}/**/*.js`), + ...testPaths.chrome.map(filePath => `${filePath}/**/*.js`), ], excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], }, @@ -228,7 +228,7 @@ module.exports = { // don't work well for HTML-based mochitests, so disable those. files: testPaths.xpcshell .concat(testPaths.browser) - .map(path => [`${path}/**/*.html`, `${path}/**/*.xhtml`]) + .map(filePath => [`${filePath}/**/*.html`, `${filePath}/**/*.xhtml`]) .flat(), rules: { // plain/chrome mochitests don't automatically include Assert, so @@ -269,7 +269,7 @@ module.exports = { }, { // Exempt files with these paths since they have to use http for full coverage - files: httpTestingPaths.map(path => `${path}**`), + files: httpTestingPaths.map(filePath => `${filePath}**`), rules: { "@microsoft/sdl/no-insecure-url": "off", }, diff --git a/.stylelintrc.js b/.stylelintrc.js index b0517609b8fc..f42de0b712c6 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -9,9 +9,9 @@ const fs = require("fs"); const path = require("path"); -function readFile(path) { +function readFile(filePath) { return fs - .readFileSync(path, { encoding: "utf-8" }) + .readFileSync(filePath, { encoding: "utf-8" }) .split("\n") .filter(p => p && !p.startsWith("#")); } diff --git a/accessible/tests/browser/.eslintrc.js b/accessible/tests/browser/.eslintrc.js index 96c085946824..90e0c2aefb20 100644 --- a/accessible/tests/browser/.eslintrc.js +++ b/accessible/tests/browser/.eslintrc.js @@ -17,7 +17,6 @@ module.exports = { "no-multi-str": "error", "no-proto": "error", "no-return-assign": "error", - "no-shadow": "error", "no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }], "one-var": ["error", "never"], radix: "error", diff --git a/browser/.eslintrc.js b/browser/.eslintrc.js index 174e444ee04e..0edc98b551fc 100644 --- a/browser/.eslintrc.js +++ b/browser/.eslintrc.js @@ -22,7 +22,5 @@ module.exports = { // Disallow adding to native types "no-extend-native": "error", - - "no-shadow": "error", }, }; diff --git a/browser/components/aboutwelcome/.eslintrc.js b/browser/components/aboutwelcome/.eslintrc.js index 0048e8275320..401f757329f6 100644 --- a/browser/components/aboutwelcome/.eslintrc.js +++ b/browser/components/aboutwelcome/.eslintrc.js @@ -151,7 +151,6 @@ module.exports = { "no-prototype-builtins": "error", "no-return-assign": ["error", "except-parens"], "no-script-url": "error", - "no-shadow": "error", "no-template-curly-in-string": "error", "no-undef-init": "error", "no-unmodified-loop-condition": "error", diff --git a/browser/components/asrouter/.eslintrc.js b/browser/components/asrouter/.eslintrc.js index 46585eedb3fb..1b50319aef53 100644 --- a/browser/components/asrouter/.eslintrc.js +++ b/browser/components/asrouter/.eslintrc.js @@ -117,7 +117,6 @@ module.exports = { "no-prototype-builtins": "error", "no-return-assign": ["error", "except-parens"], "no-script-url": "error", - "no-shadow": "error", "no-template-curly-in-string": "error", "no-undef-init": "error", "no-unmodified-loop-condition": "error", diff --git a/browser/components/extensions/test/browser/.eslintrc.js b/browser/components/extensions/test/browser/.eslintrc.js index a0509253d679..e57058ecb1c4 100644 --- a/browser/components/extensions/test/browser/.eslintrc.js +++ b/browser/components/extensions/test/browser/.eslintrc.js @@ -4,8 +4,4 @@ module.exports = { env: { webextensions: true, }, - - rules: { - "no-shadow": 0, - }, }; diff --git a/browser/components/migration/.eslintrc.js b/browser/components/migration/.eslintrc.js index 41a71782f1c2..c537f54b3c0b 100644 --- a/browser/components/migration/.eslintrc.js +++ b/browser/components/migration/.eslintrc.js @@ -12,7 +12,6 @@ module.exports = { "no-extend-native": "error", "no-multi-str": "error", "no-return-assign": "error", - "no-shadow": "error", "no-unused-vars": ["error", { argsIgnorePattern: "^_", vars: "all" }], strict: ["error", "global"], yoda: "error", diff --git a/browser/components/newtab/.eslintrc.js b/browser/components/newtab/.eslintrc.js index 7fdda287dbe4..5bf00ae2eed8 100644 --- a/browser/components/newtab/.eslintrc.js +++ b/browser/components/newtab/.eslintrc.js @@ -141,7 +141,6 @@ module.exports = { "no-prototype-builtins": "error", "no-return-assign": ["error", "except-parens"], "no-script-url": "error", - "no-shadow": "error", "no-template-curly-in-string": "error", "no-undef-init": "error", "no-unmodified-loop-condition": "error", diff --git a/devtools/.eslintrc.js b/devtools/.eslintrc.js index 909dac7d0da4..86505e71ef34 100644 --- a/devtools/.eslintrc.js +++ b/devtools/.eslintrc.js @@ -54,12 +54,6 @@ module.exports = { "mozilla/var-only-at-top-level": "off", }, }, - { - files: ["client/framework/**"], - rules: { - "no-shadow": "off", - }, - }, { files: ["client/framework/**"], rules: { @@ -233,12 +227,6 @@ module.exports = { // Disallow use of assignment in return statement. It is preferable for a // single line of code to have only one easily predictable effect. "no-return-assign": "error", - // Warn about declaration of variables already declared in the outer scope. - // This isn't an error because it sometimes is useful to use the same name - // in a small helper function rather than having to come up with another - // random name. - // Still, making this a warning can help people avoid being confused. - "no-shadow": "error", // Disallow global and local variables that aren't used. Allow unused // function arguments prefixed with `_`. "no-unused-vars": ["error", { argsIgnorePattern: "^_", vars: "all" }], diff --git a/devtools/client/debugger/src/.eslintrc.js b/devtools/client/debugger/src/.eslintrc.js index 27afb10b351a..ca439cd5130e 100644 --- a/devtools/client/debugger/src/.eslintrc.js +++ b/devtools/client/debugger/src/.eslintrc.js @@ -221,12 +221,6 @@ module.exports = { "no-self-compare": 2, // Disallow use of comma operator. "no-sequences": 2, - // Warn about declaration of variables already declared in the outer scope. - // This isn't an error because it sometimes is useful to use the same name - // in a small helper function rather than having to come up with another - // random name. - // Still, making this a warning can help people avoid being confused. - "no-shadow": 2, // Disallow sparse arrays, eg. let arr = [,,2]. // Array destructuring is fine though: // for (let [, breakpointPromise] of aPromises) diff --git a/dom/indexedDB/test/.eslintrc.js b/dom/indexedDB/test/.eslintrc.js deleted file mode 100644 index 4cb383ff7aa0..000000000000 --- a/dom/indexedDB/test/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - rules: { - "no-shadow": "off", - }, -}; diff --git a/toolkit/components/extensions/.eslintrc.js b/toolkit/components/extensions/.eslintrc.js index 2009e44ec97a..d11c70a4c318 100644 --- a/toolkit/components/extensions/.eslintrc.js +++ b/toolkit/components/extensions/.eslintrc.js @@ -163,9 +163,6 @@ module.exports = { // single line of code to have only one easily predictable effect. "no-return-assign": "error", - // Don't warn about declaration of variables already declared in the outer scope. - "no-shadow": "off", - // Allow use of synchronous methods (not a node environment). "no-sync": "off", diff --git a/toolkit/components/extensions/test/browser/.eslintrc.js b/toolkit/components/extensions/test/browser/.eslintrc.js index ef228570e302..e57058ecb1c4 100644 --- a/toolkit/components/extensions/test/browser/.eslintrc.js +++ b/toolkit/components/extensions/test/browser/.eslintrc.js @@ -4,8 +4,4 @@ module.exports = { env: { webextensions: true, }, - - rules: { - "no-shadow": "off", - }, }; diff --git a/toolkit/components/extensions/test/mochitest/.eslintrc.js b/toolkit/components/extensions/test/mochitest/.eslintrc.js index a776405c9df3..7802d13962f3 100644 --- a/toolkit/components/extensions/test/mochitest/.eslintrc.js +++ b/toolkit/components/extensions/test/mochitest/.eslintrc.js @@ -5,8 +5,4 @@ module.exports = { browser: true, webextensions: true, }, - - rules: { - "no-shadow": 0, - }, }; diff --git a/toolkit/components/narrate/.eslintrc.js b/toolkit/components/narrate/.eslintrc.js index bbd5aa34dc06..241d12a0dd0c 100644 --- a/toolkit/components/narrate/.eslintrc.js +++ b/toolkit/components/narrate/.eslintrc.js @@ -18,7 +18,6 @@ module.exports = { "no-inline-comments": "error", "no-multi-str": "error", "no-return-assign": "error", - "no-shadow": "error", strict: ["error", "global"], yoda: "error", }, diff --git a/toolkit/components/reader/.eslintrc.js b/toolkit/components/reader/.eslintrc.js index bf83f31ab111..fa17d2bb686e 100644 --- a/toolkit/components/reader/.eslintrc.js +++ b/toolkit/components/reader/.eslintrc.js @@ -7,7 +7,6 @@ module.exports = { rules: { "no-inner-declarations": "error", - "no-shadow": "error", "no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }], }, }; diff --git a/tools/lint/eslint/.eslintrc.js b/tools/lint/eslint/.eslintrc.js index 762ddba02c6f..55b4784386a3 100644 --- a/tools/lint/eslint/.eslintrc.js +++ b/tools/lint/eslint/.eslintrc.js @@ -23,7 +23,6 @@ module.exports = { rules: { camelcase: ["error", { properties: "never" }], "handle-callback-err": ["error", "er"], - "no-shadow": "error", "no-undef-init": "error", "one-var": ["error", "never"], strict: ["error", "global"], diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js index 1cf55a345388..d37bca424e1a 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js @@ -35,6 +35,5 @@ module.exports = { // Turn off use-chromeutils-generateqi as these tests don't have ChromeUtils // available. "mozilla/use-chromeutils-generateqi": "off", - "no-shadow": "error", }, }; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js index e95418c07869..1435b0b45ff1 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js @@ -285,7 +285,7 @@ module.exports = { "no-sequences": "error", // No declaring variables from an outer scope - // "no-shadow": "error", + "no-shadow": "error", // Disallow throwing literals (eg. throw "error" instead of // throw new Error("error")). diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js index 79c1121809f9..b903da343621 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js @@ -58,6 +58,5 @@ module.exports = { "mozilla/no-comparison-or-assignment-inside-ok": "error", "mozilla/no-useless-run-test": "error", - "no-shadow": "error", }, };