From 0dae27506b4d32f72c5ed2d0d2f5377b837e360d Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Sat, 24 May 2025 17:08:08 +0000 Subject: [PATCH] Bug 1881701 - Change new .eslintrc.mjs files to modules (misc), and export as flat config. r=frontend-codestyle-reviewers,webdriver-reviewers,perftest-reviewers,geckoview-reviewers,devtools-reviewers,sync-reviewers,android-reviewers,mossop,spidermonkey-reviewers,Gijs,ohall,whimboo,nchevobbe,arai,sparky,skhamis,webcompat-reviewers,twisniewski Differential Revision: https://phabricator.services.mozilla.com/D249951 --- accessible/tests/browser/.eslintrc.mjs | 50 ++-- accessible/tests/mochitest/.eslintrc.mjs | 45 ++-- dom/base/test/jsmodules/.eslintrc.mjs | 26 +- dom/fs/test/common/.eslintrc.mjs | 20 +- dom/fs/test/mochitest/worker/.eslintrc.mjs | 12 +- dom/fs/test/xpcshell/worker/.eslintrc.mjs | 12 +- dom/media/mediasource/test/.eslintrc.mjs | 58 +++-- .../test/modules/system/worker/.eslintrc.mjs | 21 +- js/src/builtin/.eslintrc.mjs | 225 +++++++++--------- mobile/android/.eslintrc.mjs | 94 ++++---- .../webcompat-reporter/.eslintrc.mjs | 112 ++++----- .../src/main/assets/messaging/.eslintrc.mjs | 12 +- .../src/main/assets/messaging/.eslintrc.mjs | 12 +- .../fenix/syncintegration/.eslintrc.mjs | 22 +- .../assets/web_extensions/.eslintrc.mjs | 30 ++- mobile/shared/.eslintrc.mjs | 80 +++---- .../components/extensions/.eslintrc.mjs | 44 ++-- .../extensions/test/mochitest/.eslintrc.mjs | 11 +- .../extensions/test/xpcshell/.eslintrc.mjs | 11 +- netwerk/test/perf/.eslintrc.mjs | 17 +- remote/marionette/.eslintrc.mjs | 14 +- remote/marionette/test/xpcshell/.eslintrc.mjs | 14 +- security/.eslintrc.mjs | 60 ++--- security/manager/ssl/tests/.eslintrc.mjs | 16 +- security/manager/tools/.eslintrc.mjs | 18 +- services/sync/tests/tps/.eslintrc.mjs | 58 +++-- taskcluster/docker/index-task/.eslintrc.mjs | 10 +- .../docker/periodic-updates/.eslintrc.mjs | 92 +++---- .../tests/files/dummy-profile/.eslintrc.mjs | 16 +- testing/performance/.eslintrc.mjs | 16 +- testing/raptor/.eslintrc.mjs | 36 +-- testing/talos/.eslintrc.mjs | 63 ++--- .../devtools/addon/content/.eslintrc.mjs | 54 +++-- .../perf-reftest-singletons/.eslintrc.mjs | 16 +- .../talos/tests/perf-reftest/.eslintrc.mjs | 16 +- tools/lint/eslint/.eslintrc.mjs | 55 +++-- .../lib/configs/.eslintrc.mjs | 16 +- tools/lint/test/files/license/.eslintrc.mjs | 2 - .../tryselect/selectors/chooser/.eslintrc.mjs | 22 +- tools/ts/.eslintrc.mjs | 26 +- 40 files changed, 809 insertions(+), 725 deletions(-) diff --git a/accessible/tests/browser/.eslintrc.mjs b/accessible/tests/browser/.eslintrc.mjs index 90e0c2aefb20..c96bc506aa2f 100644 --- a/accessible/tests/browser/.eslintrc.mjs +++ b/accessible/tests/browser/.eslintrc.mjs @@ -1,27 +1,31 @@ -"use strict"; +/* 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/. */ -module.exports = { - rules: { - "mozilla/no-aArgs": "error", - "mozilla/reject-importGlobalProperties": ["error", "everything"], - "mozilla/var-only-at-top-level": "error", +export default [ + { + rules: { + "mozilla/no-aArgs": "error", + "mozilla/reject-importGlobalProperties": ["error", "everything"], + "mozilla/var-only-at-top-level": "error", - "block-scoped-var": "error", - camelcase: ["error", { properties: "never" }], - complexity: ["error", 20], + "block-scoped-var": "error", + camelcase: ["error", { properties: "never" }], + complexity: ["error", 20], - "handle-callback-err": ["error", "er"], - "max-nested-callbacks": ["error", 4], - "new-cap": ["error", { capIsNew: false }], - "no-fallthrough": "error", - "no-multi-str": "error", - "no-proto": "error", - "no-return-assign": "error", - "no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }], - "one-var": ["error", "never"], - radix: "error", - strict: ["error", "global"], - yoda: "error", - "no-undef-init": "error", + "handle-callback-err": ["error", "er"], + "max-nested-callbacks": ["error", 4], + "new-cap": ["error", { capIsNew: false }], + "no-fallthrough": "error", + "no-multi-str": "error", + "no-proto": "error", + "no-return-assign": "error", + "no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }], + "one-var": ["error", "never"], + radix: "error", + strict: ["error", "global"], + yoda: "error", + "no-undef-init": "error", + }, }, -}; +]; diff --git a/accessible/tests/mochitest/.eslintrc.mjs b/accessible/tests/mochitest/.eslintrc.mjs index 2ce1c5017a5c..a92fe51628bb 100644 --- a/accessible/tests/mochitest/.eslintrc.mjs +++ b/accessible/tests/mochitest/.eslintrc.mjs @@ -1,24 +1,25 @@ -"use strict"; +/* 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/. */ -module.exports = { - rules: { - // XXX These are rules that are enabled in the recommended configuration, but - // disabled here due to failures when initially implemented. They should be - // removed (and hence enabled) at some stage. - "no-nested-ternary": "off", - }, - - overrides: [ - { - files: [ - // Bug 1602061 TODO: These tests access DOM elements via - // id-as-variable-name, which eslint doesn't have support for yet. - "attributes/test_listbox.html", - "treeupdate/test_ariaowns.html", - ], - rules: { - "no-undef": "off", - }, +export default [ + { + rules: { + // XXX These are rules that are enabled in the recommended configuration, but + // disabled here due to failures when initially implemented. They should be + // removed (and hence enabled) at some stage. + "no-nested-ternary": "off", }, - ], -}; + }, + { + files: [ + // Bug 1602061 TODO: These tests access DOM elements via + // id-as-variable-name, which eslint doesn't have support for yet. + "attributes/test_listbox.html", + "treeupdate/test_ariaowns.html", + ], + rules: { + "no-undef": "off", + }, + }, +]; diff --git a/dom/base/test/jsmodules/.eslintrc.mjs b/dom/base/test/jsmodules/.eslintrc.mjs index 25a38d20af27..5ad79773420c 100644 --- a/dom/base/test/jsmodules/.eslintrc.mjs +++ b/dom/base/test/jsmodules/.eslintrc.mjs @@ -1,15 +1,15 @@ -"use strict"; +/* 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/. */ -module.exports = { - overrides: [ - { - // eslint-plugin-html doesn't automatically detect module sections in - // html files. Enable these as a module here. JavaScript files can use - // the mjs extension. - files: ["*.html"], - parserOptions: { - sourceType: "module", - }, +export default [ + { + // eslint-plugin-html doesn't automatically detect module sections in + // html files. Enable these as a module here. JavaScript files can use + // the mjs extension. + files: ["**/*.html"], + languageOptions: { + sourceType: "module", }, - ], -}; + }, +]; diff --git a/dom/fs/test/common/.eslintrc.mjs b/dom/fs/test/common/.eslintrc.mjs index d805cf6e0f0e..aa6c69776208 100644 --- a/dom/fs/test/common/.eslintrc.mjs +++ b/dom/fs/test/common/.eslintrc.mjs @@ -2,13 +2,15 @@ * 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/. */ -"use strict"; - -module.exports = { - globals: { - Assert: true, - exported_symbols: true, - require_module: true, - Utils: true, +export default [ + { + languageOptions: { + globals: { + Assert: true, + exported_symbols: true, + require_module: true, + Utils: true, + }, + }, }, -}; +]; diff --git a/dom/fs/test/mochitest/worker/.eslintrc.mjs b/dom/fs/test/mochitest/worker/.eslintrc.mjs index 93bf938654ab..8efc103c05a4 100644 --- a/dom/fs/test/mochitest/worker/.eslintrc.mjs +++ b/dom/fs/test/mochitest/worker/.eslintrc.mjs @@ -3,10 +3,12 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - worker: true, +export default [ + { + languageOptions: { + globals: globals.worker, + }, }, -}; +]; diff --git a/dom/fs/test/xpcshell/worker/.eslintrc.mjs b/dom/fs/test/xpcshell/worker/.eslintrc.mjs index 93bf938654ab..8efc103c05a4 100644 --- a/dom/fs/test/xpcshell/worker/.eslintrc.mjs +++ b/dom/fs/test/xpcshell/worker/.eslintrc.mjs @@ -3,10 +3,12 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - worker: true, +export default [ + { + languageOptions: { + globals: globals.worker, + }, }, -}; +]; diff --git a/dom/media/mediasource/test/.eslintrc.mjs b/dom/media/mediasource/test/.eslintrc.mjs index e283e384ba7d..dbcb36f86917 100644 --- a/dom/media/mediasource/test/.eslintrc.mjs +++ b/dom/media/mediasource/test/.eslintrc.mjs @@ -1,28 +1,34 @@ -"use strict"; +/* 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/. */ -module.exports = { - // Globals from mediasource.js. We use false to indicate they should not - // be overwritten in scripts. - globals: { - addMSEPrefs: false, - fetchAndLoad: false, - fetchAndLoadAsync: false, - fetchWithXHR: false, - logEvents: false, - loadSegment: false, - must_not_reject: false, - must_not_throw: false, - must_reject: false, - must_throw: false, - once: false, - range: false, - runWithMSE: false, - wait: false, - waitUntilTime: false, +export default [ + { + // Globals from mediasource.js. We use false to indicate they should not + // be overwritten in scripts. + languageOptions: { + globals: { + addMSEPrefs: false, + fetchAndLoad: false, + fetchAndLoadAsync: false, + fetchWithXHR: false, + logEvents: false, + loadSegment: false, + must_not_reject: false, + must_not_throw: false, + must_reject: false, + must_throw: false, + once: false, + range: false, + runWithMSE: false, + wait: false, + waitUntilTime: false, + }, + }, + // Use const/let instead of var for tighter scoping, avoiding redeclaration + rules: { + "no-var": "error", + "prefer-const": "error", + }, }, - // Use const/let instead of var for tighter scoping, avoiding redeclaration - rules: { - "no-var": "error", - "prefer-const": "error", - }, -}; +]; diff --git a/dom/quota/test/modules/system/worker/.eslintrc.mjs b/dom/quota/test/modules/system/worker/.eslintrc.mjs index 505e079c5769..8efc103c05a4 100644 --- a/dom/quota/test/modules/system/worker/.eslintrc.mjs +++ b/dom/quota/test/modules/system/worker/.eslintrc.mjs @@ -3,19 +3,12 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - worker: true, - }, - - overrides: [ - { - files: ["head.js"], - env: { - worker: true, - }, +export default [ + { + languageOptions: { + globals: globals.worker, }, - ], -}; + }, +]; diff --git a/js/src/builtin/.eslintrc.mjs b/js/src/builtin/.eslintrc.mjs index 829b1124093f..262c659ef8ca 100644 --- a/js/src/builtin/.eslintrc.mjs +++ b/js/src/builtin/.eslintrc.mjs @@ -2,35 +2,107 @@ * 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/. */ -"use strict"; +import spidermonkeyJS from "eslint-plugin-spidermonkey-js"; +import mozilla from "eslint-plugin-mozilla"; +import globals from "globals"; -module.exports = { - plugins: ["spidermonkey-js"], +export default [ + { + plugins: { "spidermonkey-js": spidermonkeyJS }, + files: ["**/*.js"], + processor: "spidermonkey-js/processor", - overrides: [ - { - files: ["*.js"], - excludedFiles: ".eslintrc.js", - processor: "spidermonkey-js/processor", - env: { - // Disable all built-in environments. - node: false, - browser: false, - builtin: false, - - // We need to explicitly disable the default environments added from - // "tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js". - es2021: false, - "mozilla/privileged": false, - "mozilla/specific": false, - - // Enable SpiderMonkey's self-hosted environment. - "spidermonkey-js/environment": true, - }, + rules: { + // We should fix those at some point, but we use this to detect NaNs. + "no-self-compare": "off", + "no-lonely-if": "off", + // Disabled until we can use let/const to fix those erorrs, and undefined + // names cause an exception and abort during runtime initialization. + "no-redeclare": "off", + // Disallow use of |void 0|. Instead use |undefined|. + "no-void": ["error", { allowAsStatement: true }], + // Disallow loose equality because of objects with the [[IsHTMLDDA]] + // internal slot, aka |document.all|, aka "objects emulating undefined". + eqeqeq: "error", + // All self-hosted code is implicitly strict mode, so there's no need to + // add a strict-mode directive. + strict: ["error", "never"], + // Disallow syntax not supported in self-hosted code. + "no-restricted-syntax": [ + "error", + { + selector: "ClassDeclaration", + message: "Class declarations are not allowed", + }, + { + selector: "ClassExpression", + message: "Class expressions are not allowed", + }, + { + selector: "Literal[regex]", + message: "Regular expression literals are not allowed", + }, + { + selector: "CallExpression > MemberExpression.callee", + message: + "Direct method calls are not allowed, use callFunction() or callContentFunction()", + }, + { + selector: "NewExpression > MemberExpression.callee", + message: + "Direct method calls are not allowed, use constructContentFunction()", + }, + { + selector: "YieldExpression[delegate=true]", + message: + "yield* is not allowed because it can run user-modifiable iteration code", + }, + { + selector: "ForOfStatement > :not(CallExpression).right", + message: + "for-of loops must use allowContentIter(), allowContentIterWith(), or allowContentIterWithNext()", + }, + { + selector: + "ForOfStatement > CallExpression.right > :not(Identifier[name='allowContentIter'], Identifier[name='allowContentIterWith'], Identifier[name='allowContentIterWithNext']).callee", + message: + "for-of loops must use allowContentIter(), allowContentIterWith(), or allowContentIterWithNext", + }, + { + selector: + "CallExpression[callee.name='TO_PROPERTY_KEY'] > :not(Identifier).arguments:first-child", + message: + "TO_PROPERTY_KEY macro must be called with a simple identifier", + }, + { + selector: "Identifier[name='arguments']", + message: + "'arguments' is disallowed, use ArgumentsLength(), GetArgument(n), or rest-parameters", + }, + { + selector: "VariableDeclaration[kind='let']", + message: + "'let' declarations are disallowed to avoid TDZ checks, use 'var' instead", + }, + { + selector: "VariableDeclaration[kind='const']", + message: + "'const' declarations are disallowed to avoid TDZ checks, use 'var' instead", + }, + ], + // Method signatures are important in builtins so disable unused argument errors. + "no-unused-vars": [ + "error", + { + args: "none", + vars: "local", + }, + ], + }, + languageOptions: { parserOptions: { ecmaVersion: "latest", - sourceType: "script", // Self-hosted code defaults to strict mode. ecmaFeatures: { @@ -45,93 +117,22 @@ module.exports = { }, }, - rules: { - // We should fix those at some point, but we use this to detect NaNs. - "no-self-compare": "off", - "no-lonely-if": "off", - // Disabled until we can use let/const to fix those erorrs, and undefined - // names cause an exception and abort during runtime initialization. - "no-redeclare": "off", - // Disallow use of |void 0|. Instead use |undefined|. - "no-void": ["error", { allowAsStatement: true }], - // Disallow loose equality because of objects with the [[IsHTMLDDA]] - // internal slot, aka |document.all|, aka "objects emulating undefined". - eqeqeq: "error", - // All self-hosted code is implicitly strict mode, so there's no need to - // add a strict-mode directive. - strict: ["error", "never"], - // Disallow syntax not supported in self-hosted code. - "no-restricted-syntax": [ - "error", - { - selector: "ClassDeclaration", - message: "Class declarations are not allowed", - }, - { - selector: "ClassExpression", - message: "Class expressions are not allowed", - }, - { - selector: "Literal[regex]", - message: "Regular expression literals are not allowed", - }, - { - selector: "CallExpression > MemberExpression.callee", - message: - "Direct method calls are not allowed, use callFunction() or callContentFunction()", - }, - { - selector: "NewExpression > MemberExpression.callee", - message: - "Direct method calls are not allowed, use constructContentFunction()", - }, - { - selector: "YieldExpression[delegate=true]", - message: - "yield* is not allowed because it can run user-modifiable iteration code", - }, - { - selector: "ForOfStatement > :not(CallExpression).right", - message: - "for-of loops must use allowContentIter(), allowContentIterWith(), or allowContentIterWithNext()", - }, - { - selector: - "ForOfStatement > CallExpression.right > :not(Identifier[name='allowContentIter'], Identifier[name='allowContentIterWith'], Identifier[name='allowContentIterWithNext']).callee", - message: - "for-of loops must use allowContentIter(), allowContentIterWith(), or allowContentIterWithNext", - }, - { - selector: - "CallExpression[callee.name='TO_PROPERTY_KEY'] > :not(Identifier).arguments:first-child", - message: - "TO_PROPERTY_KEY macro must be called with a simple identifier", - }, - { - selector: "Identifier[name='arguments']", - message: - "'arguments' is disallowed, use ArgumentsLength(), GetArgument(n), or rest-parameters", - }, - { - selector: "VariableDeclaration[kind='let']", - message: "'let' declarations are disallowed to avoid TDZ checks, use 'var' instead", - }, - { - selector: "VariableDeclaration[kind='const']", - message: "'const' declarations are disallowed to avoid TDZ checks, use 'var' instead", - }, - ], - // Method signatures are important in builtins so disable unused argument errors. - "no-unused-vars": [ - "error", - { - args: "none", - vars: "local", - }, - ], - }, - + sourceType: "script", globals: { + // Disable all built-in environments. + ...mozilla.turnOff(globals.node), + ...mozilla.turnOff(globals.browser), + ...mozilla.turnOff(globals.builtin), + + // We need to explicitly disable the default environments added from + // "tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js". + ...mozilla.turnOff(globals.es2021), + ...mozilla.turnOff(mozilla.environments.privileged.globals), + ...mozilla.turnOff(mozilla.environments.specific.globals), + + // Enable SpiderMonkey's self-hosted environment. + ...spidermonkeyJS.environments.environment.globals, + // The bytecode compiler special-cases these identifiers. ArgumentsLength: "readonly", allowContentIter: "readonly", @@ -173,5 +174,5 @@ module.exports = { Tuple: "off", }, }, - ], -}; + }, +]; diff --git a/mobile/android/.eslintrc.mjs b/mobile/android/.eslintrc.mjs index 684f782f95e7..e892cffb2213 100644 --- a/mobile/android/.eslintrc.mjs +++ b/mobile/android/.eslintrc.mjs @@ -2,19 +2,15 @@ * 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/. */ -"use strict"; +import config from "../../toolkit/components/extensions/parent/.eslintrc.mjs"; -const { - globals, -} = require("../../toolkit/components/extensions/parent/.eslintrc.js"); - -module.exports = { - overrides: [ - { - files: ["components/extensions/ext-*.js"], - excludedFiles: ["components/extensions/ext-c-*.js"], +export default [ + { + files: ["components/extensions/ext-*.js"], + ignores: ["components/extensions/ext-c-*.js"], + languageOptions: { globals: { - ...globals, + ...config[0].globals, // These globals are defined in ext-android.js and can only be used in // the extension files that run in the parent process. EventDispatcher: true, @@ -25,49 +21,49 @@ module.exports = { windowTracker: true, }, }, - { - files: [ - "chrome/geckoview/**", - "components/geckoview/**", - "modules/geckoview/**", - "actors/**", + }, + { + files: [ + "chrome/geckoview/**", + "components/geckoview/**", + "modules/geckoview/**", + "actors/**", + ], + rules: { + "no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + vars: "local", + varsIgnorePattern: "(debug|warn)", + }, ], - rules: { - "no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - vars: "local", - varsIgnorePattern: "(debug|warn)", - }, - ], - "no-restricted-syntax": [ - "error", - { - selector: `CallExpression > \ + "no-restricted-syntax": [ + "error", + { + selector: `CallExpression > \ Identifier.callee[name = /^debug$|^warn$/]`, - message: - "Use debug and warn with template literals, e.g. debug `foo`;", - }, - { - selector: `BinaryExpression[operator = '+'] > \ + message: + "Use debug and warn with template literals, e.g. debug `foo`;", + }, + { + selector: `BinaryExpression[operator = '+'] > \ TaggedTemplateExpression.left > \ Identifier.tag[name = /^debug$|^warn$/]`, - message: - "Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" + - " e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)", - }, - { - selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \ + message: + "Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" + + " e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)", + }, + { + selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \ TemplateLiteral.quasi CallExpression > \ MemberExpression.callee[object.type = 'Identifier'][object.name = 'JSON'] > \ Identifier.property[name = 'stringify']`, - message: - "Don't call JSON.stringify within debug/warn literals,\n" + - " e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)", - }, - ], - }, + message: + "Don't call JSON.stringify within debug/warn literals,\n" + + " e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)", + }, + ], }, - ], -}; + }, +]; diff --git a/mobile/android/android-components/components/feature/webcompat-reporter/src/main/assets/extensions/webcompat-reporter/.eslintrc.mjs b/mobile/android/android-components/components/feature/webcompat-reporter/src/main/assets/extensions/webcompat-reporter/.eslintrc.mjs index e26bd6da3f11..e737ac1ab60d 100644 --- a/mobile/android/android-components/components/feature/webcompat-reporter/src/main/assets/extensions/webcompat-reporter/.eslintrc.mjs +++ b/mobile/android/android-components/components/feature/webcompat-reporter/src/main/assets/extensions/webcompat-reporter/.eslintrc.mjs @@ -2,75 +2,79 @@ * 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/. */ -"use strict"; +import mozilla from "eslint-plugin-mozilla"; -module.exports = { - rules: { - // Rules from the mozilla plugin - "mozilla/balanced-listeners": "error", - "mozilla/no-aArgs": "error", - "mozilla/var-only-at-top-level": "error", +export default [ + { + plugins: { mozilla }, - "valid-jsdoc": [ - "error", - { - prefer: { - return: "returns", + rules: { + // Rules from the mozilla plugin + "mozilla/balanced-listeners": "error", + "mozilla/no-aArgs": "error", + "mozilla/var-only-at-top-level": "error", + + "valid-jsdoc": [ + "error", + { + prefer: { + return: "returns", + }, + preferType: { + Boolean: "boolean", + Number: "number", + String: "string", + bool: "boolean", + }, + requireParamDescription: false, + requireReturn: false, + requireReturnDescription: false, }, - preferType: { - Boolean: "boolean", - Number: "number", - String: "string", - bool: "boolean", - }, - requireParamDescription: false, - requireReturn: false, - requireReturnDescription: false, - }, - ], + ], - // No expressions where a statement is expected - "no-unused-expressions": "error", + // No expressions where a statement is expected + "no-unused-expressions": "error", - // No declaring variables that are never used - "no-unused-vars": "error", + // No declaring variables that are never used + "no-unused-vars": "error", - // Disallow using variables outside the blocks they are defined (especially - // since only let and const are used, see "no-var"). - "block-scoped-var": "error", + // Disallow using variables outside the blocks they are defined (especially + // since only let and const are used, see "no-var"). + "block-scoped-var": "error", - // Warn about cyclomatic complexity in functions. - complexity: ["error", { max: 26 }], + // Warn about cyclomatic complexity in functions. + complexity: ["error", { max: 26 }], - // Maximum depth callbacks can be nested. - "max-nested-callbacks": ["error", 4], + // Maximum depth callbacks can be nested. + "max-nested-callbacks": ["error", 4], - // Allow the console API aside from console.log. - "no-console": ["error", { allow: ["error", "info", "trace", "warn"] }], + // Allow the console API aside from console.log. + "no-console": ["error", { allow: ["error", "info", "trace", "warn"] }], - // Disallow fallthrough of case statements, except if there is a comment. - "no-fallthrough": "error", + // Disallow fallthrough of case statements, except if there is a comment. + "no-fallthrough": "error", - // Disallow use of multiline strings (use template strings instead). - "no-multi-str": "error", + // Disallow use of multiline strings (use template strings instead). + "no-multi-str": "error", - // Disallow usage of __proto__ property. - "no-proto": "error", + // Disallow usage of __proto__ property. + "no-proto": "error", - // 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", + // 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", - // Require use of the second argument for parseInt(). - radix: "error", + // Require use of the second argument for parseInt(). + radix: "error", - // Require "use strict" to be defined globally in the script. - strict: ["error", "global"], + // Require "use strict" to be defined globally in the script. + strict: ["error", "global"], - // Disallow Yoda conditions (where literal value comes first). - yoda: "error", + // Disallow Yoda conditions (where literal value comes first). + yoda: "error", - // Disallow function or variable declarations in nested blocks - "no-inner-declarations": "error", + // Disallow function or variable declarations in nested blocks + "no-inner-declarations": "error", + }, }, -}; +]; diff --git a/mobile/android/examples/messaging_example/app/src/main/assets/messaging/.eslintrc.mjs b/mobile/android/examples/messaging_example/app/src/main/assets/messaging/.eslintrc.mjs index c5fda0067641..f2258348a771 100644 --- a/mobile/android/examples/messaging_example/app/src/main/assets/messaging/.eslintrc.mjs +++ b/mobile/android/examples/messaging_example/app/src/main/assets/messaging/.eslintrc.mjs @@ -2,10 +2,12 @@ * 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/. */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - webextensions: true, +export default [ + { + languageOptions: { + globals: globals.webextensions, + }, }, -}; +]; diff --git a/mobile/android/examples/port_messaging_example/app/src/main/assets/messaging/.eslintrc.mjs b/mobile/android/examples/port_messaging_example/app/src/main/assets/messaging/.eslintrc.mjs index c5fda0067641..f2258348a771 100644 --- a/mobile/android/examples/port_messaging_example/app/src/main/assets/messaging/.eslintrc.mjs +++ b/mobile/android/examples/port_messaging_example/app/src/main/assets/messaging/.eslintrc.mjs @@ -2,10 +2,12 @@ * 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/. */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - webextensions: true, +export default [ + { + languageOptions: { + globals: globals.webextensions, + }, }, -}; +]; diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/.eslintrc.mjs b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/.eslintrc.mjs index fd9d3f1789a8..545bfeb3e453 100644 --- a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/.eslintrc.mjs +++ b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/.eslintrc.mjs @@ -2,14 +2,16 @@ * 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/. */ -"use strict"; - -module.exports = { - globals: { - Bookmarks: false, - EnableEngines: false, - Passwords: false, - Phase: false, - Sync: false, +export default [ + { + languageOptions: { + globals: { + Bookmarks: false, + EnableEngines: false, + Passwords: false, + Phase: false, + Sync: false, + }, + }, }, -}; +]; diff --git a/mobile/android/geckoview/src/androidTest/assets/web_extensions/.eslintrc.mjs b/mobile/android/geckoview/src/androidTest/assets/web_extensions/.eslintrc.mjs index 41c5ed808074..682f5eb1d8ab 100644 --- a/mobile/android/geckoview/src/androidTest/assets/web_extensions/.eslintrc.mjs +++ b/mobile/android/geckoview/src/androidTest/assets/web_extensions/.eslintrc.mjs @@ -1,14 +1,20 @@ -"use strict"; +/* 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/. */ -module.exports = { - env: { - webextensions: true, +import globals from "globals"; + +export default [ + { + languageOptions: { + globals: { + ...globals.webextensions, + ExtensionAPI: true, + // available to frameScripts + addMessageListener: false, + content: false, + sendAsyncMessage: false, + }, + }, }, - globals: { - ExtensionAPI: true, - // available to frameScripts - addMessageListener: false, - content: false, - sendAsyncMessage: false, - }, -}; +]; diff --git a/mobile/shared/.eslintrc.mjs b/mobile/shared/.eslintrc.mjs index d69758c786c8..cba6438697ee 100644 --- a/mobile/shared/.eslintrc.mjs +++ b/mobile/shared/.eslintrc.mjs @@ -2,53 +2,49 @@ * 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/. */ -"use strict"; - -module.exports = { - overrides: [ - { - files: [ - "chrome/geckoview/**", - "components/geckoview/**", - "modules/geckoview/**", - "actors/**", +export default [ + { + files: [ + "chrome/geckoview/**", + "components/geckoview/**", + "modules/geckoview/**", + "actors/**", + ], + rules: { + "no-unused-vars": [ + "error", + { + args: "none", + vars: "local", + varsIgnorePattern: "(debug|warn)", + }, ], - rules: { - "no-unused-vars": [ - "error", - { - args: "none", - vars: "local", - varsIgnorePattern: "(debug|warn)", - }, - ], - "no-restricted-syntax": [ - "error", - { - selector: `CallExpression > \ + "no-restricted-syntax": [ + "error", + { + selector: `CallExpression > \ Identifier.callee[name = /^debug$|^warn$/]`, - message: - "Use debug and warn with template literals, e.g. debug `foo`;", - }, - { - selector: `BinaryExpression[operator = '+'] > \ + message: + "Use debug and warn with template literals, e.g. debug `foo`;", + }, + { + selector: `BinaryExpression[operator = '+'] > \ TaggedTemplateExpression.left > \ Identifier.tag[name = /^debug$|^warn$/]`, - message: - "Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" + - " e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)", - }, - { - selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \ + message: + "Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" + + " e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)", + }, + { + selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \ TemplateLiteral.quasi CallExpression > \ MemberExpression.callee[object.type = 'Identifier'][object.name = 'JSON'] > \ Identifier.property[name = 'stringify']`, - message: - "Don't call JSON.stringify within debug/warn literals,\n" + - " e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)", - }, - ], - }, + message: + "Don't call JSON.stringify within debug/warn literals,\n" + + " e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)", + }, + ], }, - ], -}; + }, +]; diff --git a/mobile/shared/components/extensions/.eslintrc.mjs b/mobile/shared/components/extensions/.eslintrc.mjs index 9e2a1580df38..1b64a637c9cc 100644 --- a/mobile/shared/components/extensions/.eslintrc.mjs +++ b/mobile/shared/components/extensions/.eslintrc.mjs @@ -2,28 +2,22 @@ * 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/. */ -"use strict"; +import toolkitConfig from "../../../../toolkit/components/extensions/.eslintrc.mjs"; +import parentConfig from "../../../../toolkit/components/extensions/parent/.eslintrc.mjs"; +import childConfig from "../../../../toolkit/components/extensions/child/.eslintrc.mjs"; -const { - globals: globalsParent, -} = require("../../../../toolkit/components/extensions/parent/.eslintrc.js"); - -const { - globals: globalsChild, -} = require("../../../../toolkit/components/extensions/child/.eslintrc.js"); - -module.exports = { - extends: "../../../../toolkit/components/extensions/.eslintrc.js", +export default [ + ...toolkitConfig, // Ideally mobile should also follow the convention of // parent/ext-*.js for parent scripts and // child/ext-*.js for child scripts, // but the current file structure predates the parent/ vs child/ separation. - overrides: [ - { - files: ["ext-*.js"], - excludedFiles: ["ext-c-*.js"], + { + files: ["ext-*.js"], + ignores: ["ext-c-*.js"], + languageOptions: { globals: { - ...globalsParent, + ...parentConfig[0].languageOptions.globals, // These globals are defined in ext-android.js and can only be used in // the extension files that run in the parent process. EventDispatcher: true, @@ -34,13 +28,11 @@ module.exports = { windowTracker: true, }, }, - { - files: ["ext-c-*.js"], - globals: { - ...globalsChild, - // If there were ever globals exported in ext-c-android.js for common - // use, then they would appear here. - }, - }, - ], -}; + }, + { + files: ["ext-c-*.js"], + // If there were ever globals exported in ext-c-android.js for common + // use, then they would appear here. + ...childConfig[0], + }, +]; diff --git a/mobile/shared/components/extensions/test/mochitest/.eslintrc.mjs b/mobile/shared/components/extensions/test/mochitest/.eslintrc.mjs index 7d6fe2eb1a1a..27ea4bf5ab65 100644 --- a/mobile/shared/components/extensions/test/mochitest/.eslintrc.mjs +++ b/mobile/shared/components/extensions/test/mochitest/.eslintrc.mjs @@ -1,6 +1,7 @@ -"use strict"; +/* 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/. */ -module.exports = { - extends: - "../../../../../../toolkit/components/extensions/test/mochitest/.eslintrc.js", -}; +import config from "../../../../../../toolkit/components/extensions/test/mochitest/.eslintrc.mjs"; + +export default config; diff --git a/mobile/shared/components/extensions/test/xpcshell/.eslintrc.mjs b/mobile/shared/components/extensions/test/xpcshell/.eslintrc.mjs index 2e6d214f4b2a..174facbc6457 100644 --- a/mobile/shared/components/extensions/test/xpcshell/.eslintrc.mjs +++ b/mobile/shared/components/extensions/test/xpcshell/.eslintrc.mjs @@ -1,6 +1,7 @@ -"use strict"; +/* 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/. */ -module.exports = { - extends: - "../../../../../../toolkit/components/extensions/test/xpcshell/.eslintrc.js", -}; +import config from "../../../../../../toolkit/components/extensions/test/xpcshell/.eslintrc.mjs"; + +export default config; diff --git a/netwerk/test/perf/.eslintrc.mjs b/netwerk/test/perf/.eslintrc.mjs index f04003250994..ee9a6dfe1640 100644 --- a/netwerk/test/perf/.eslintrc.mjs +++ b/netwerk/test/perf/.eslintrc.mjs @@ -2,11 +2,16 @@ * 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/. */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - browser: true, - node: true, +export default [ + { + files: ["**/*.js"], + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, }, -}; +]; diff --git a/remote/marionette/.eslintrc.mjs b/remote/marionette/.eslintrc.mjs index 64a8883c43b8..00a7a78fd605 100644 --- a/remote/marionette/.eslintrc.mjs +++ b/remote/marionette/.eslintrc.mjs @@ -2,13 +2,13 @@ * 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/. */ -"use strict"; - // inherits from ../../tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js -module.exports = { - rules: { - camelcase: ["error", { properties: "never" }], - "no-var": "error", +export default [ + { + rules: { + camelcase: ["error", { properties: "never" }], + "no-var": "error", + }, }, -}; +]; diff --git a/remote/marionette/test/xpcshell/.eslintrc.mjs b/remote/marionette/test/xpcshell/.eslintrc.mjs index 2ef179ab5ec9..be63fceeb854 100644 --- a/remote/marionette/test/xpcshell/.eslintrc.mjs +++ b/remote/marionette/test/xpcshell/.eslintrc.mjs @@ -1,7 +1,11 @@ -"use strict"; +/* 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/. */ -module.exports = { - rules: { - camelcase: "off", +export default [ + { + rules: { + camelcase: "off", + }, }, -}; +]; diff --git a/security/.eslintrc.mjs b/security/.eslintrc.mjs index b99ca306cfba..86f525b902c2 100644 --- a/security/.eslintrc.mjs +++ b/security/.eslintrc.mjs @@ -2,45 +2,45 @@ * 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/. */ -"use strict"; +export default [ + { + rules: { + // Enforce return statements in callbacks of array methods. + "array-callback-return": "error", -module.exports = { - rules: { - // Enforce return statements in callbacks of array methods. - "array-callback-return": "error", + // Require default case in switch statements. + "default-case": "error", - // Require default case in switch statements. - "default-case": "error", + // Disallow use of alert(), confirm(), and prompt(). + "no-alert": "error", - // Disallow use of alert(), confirm(), and prompt(). - "no-alert": "error", + // Disallow likely erroneous `switch` scoped lexical declarations in + // case/default clauses. + "no-case-declarations": "error", - // Disallow likely erroneous `switch` scoped lexical declarations in - // case/default clauses. - "no-case-declarations": "error", + // Disallow constant expressions in conditions (except for loops). + "no-constant-condition": ["error", { checkLoops: false }], - // Disallow constant expressions in conditions (except for loops). - "no-constant-condition": ["error", { checkLoops: false }], + // Disallow extending of native objects. + "no-extend-native": "error", - // Disallow extending of native objects. - "no-extend-native": "error", + // Disallow use of assignment in return statement. + "no-return-assign": ["error", "always"], - // Disallow use of assignment in return statement. - "no-return-assign": ["error", "always"], + // Disallow template literal placeholder syntax in regular strings. + "no-template-curly-in-string": "error", - // Disallow template literal placeholder syntax in regular strings. - "no-template-curly-in-string": "error", + // Disallow unmodified loop conditions. + "no-unmodified-loop-condition": "error", - // Disallow unmodified loop conditions. - "no-unmodified-loop-condition": "error", + // No expressions where a statement is expected + "no-unused-expressions": "error", - // No expressions where a statement is expected - "no-unused-expressions": "error", + // Require "use strict" to be defined globally in the script. + strict: ["error", "global"], - // Require "use strict" to be defined globally in the script. - strict: ["error", "global"], - - // Disallow Yoda conditions. - yoda: ["error", "never"], + // Disallow Yoda conditions. + yoda: ["error", "never"], + }, }, -}; +]; diff --git a/security/manager/ssl/tests/.eslintrc.mjs b/security/manager/ssl/tests/.eslintrc.mjs index 379eabb2d05d..88d1c1640869 100644 --- a/security/manager/ssl/tests/.eslintrc.mjs +++ b/security/manager/ssl/tests/.eslintrc.mjs @@ -1,8 +1,12 @@ -"use strict"; +/* 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/. */ -module.exports = { - rules: { - // Disallow non-top level |var| declarations. - "mozilla/var-only-at-top-level": "error", +export default [ + { + rules: { + // Disallow non-top level |var| declarations. + "mozilla/var-only-at-top-level": "error", + }, }, -}; +]; diff --git a/security/manager/tools/.eslintrc.mjs b/security/manager/tools/.eslintrc.mjs index 44c1d9cba600..b575c7c92e64 100644 --- a/security/manager/tools/.eslintrc.mjs +++ b/security/manager/tools/.eslintrc.mjs @@ -2,12 +2,14 @@ * 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/. */ -"use strict"; - -module.exports = { - globals: { - // JS files in this folder are commonly xpcshell scripts where |arguments| - // is defined in the global scope. - arguments: false, +export default [ + { + languageOptions: { + globals: { + // JS files in this folder are commonly xpcshell scripts where |arguments| + // is defined in the global scope. + arguments: false, + }, + }, }, -}; +]; diff --git a/services/sync/tests/tps/.eslintrc.mjs b/services/sync/tests/tps/.eslintrc.mjs index 63c834493480..ec5cb45d578b 100644 --- a/services/sync/tests/tps/.eslintrc.mjs +++ b/services/sync/tests/tps/.eslintrc.mjs @@ -1,28 +1,34 @@ -"use strict"; +/* 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/. */ -module.exports = { - globals: { - // Injected into tests via tps.sys.mjs - Addons: false, - Addresses: false, - Bookmarks: false, - CreditCards: false, - EnableEngines: false, - EnsureTracking: false, - ExtStorage: false, - Formdata: false, - History: false, - Login: false, - Passwords: false, - Phase: false, - Prefs: false, - STATE_DISABLED: false, - STATE_ENABLED: false, - Sync: false, - SYNC_WIPE_CLIENT: false, - SYNC_WIPE_REMOTE: false, - Tabs: false, - Windows: false, - WipeServer: false, +export default [ + { + languageOptions: { + globals: { + // Injected into tests via tps.sys.mjs + Addons: false, + Addresses: false, + Bookmarks: false, + CreditCards: false, + EnableEngines: false, + EnsureTracking: false, + ExtStorage: false, + Formdata: false, + History: false, + Login: false, + Passwords: false, + Phase: false, + Prefs: false, + STATE_DISABLED: false, + STATE_ENABLED: false, + Sync: false, + SYNC_WIPE_CLIENT: false, + SYNC_WIPE_REMOTE: false, + Tabs: false, + Windows: false, + WipeServer: false, + }, + }, }, -}; +]; diff --git a/taskcluster/docker/index-task/.eslintrc.mjs b/taskcluster/docker/index-task/.eslintrc.mjs index ff84d9cb69a9..2270f598ddcd 100644 --- a/taskcluster/docker/index-task/.eslintrc.mjs +++ b/taskcluster/docker/index-task/.eslintrc.mjs @@ -2,10 +2,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/. */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - node: true, +export default [ + { + languageOptions: { globals: globals.node }, }, -}; +]; diff --git a/taskcluster/docker/periodic-updates/.eslintrc.mjs b/taskcluster/docker/periodic-updates/.eslintrc.mjs index 508b1cfbce2d..fcf43c7dcf3f 100644 --- a/taskcluster/docker/periodic-updates/.eslintrc.mjs +++ b/taskcluster/docker/periodic-updates/.eslintrc.mjs @@ -2,50 +2,52 @@ * 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/. */ -"use strict"; +export default [ + { + languageOptions: { + globals: { + // JS files in this folder are commonly xpcshell scripts where |arguments| + // is defined in the global scope. + arguments: false, + }, + }, + rules: { + // Enforce return statements in callbacks of array methods. + "array-callback-return": "error", -module.exports = { - globals: { - // JS files in this folder are commonly xpcshell scripts where |arguments| - // is defined in the global scope. - arguments: false, + // Require default case in switch statements. + "default-case": "error", + + // Disallow use of alert(), confirm(), and prompt(). + "no-alert": "error", + + // Disallow likely erroneous `switch` scoped lexical declarations in + // case/default clauses. + "no-case-declarations": "error", + + // Disallow constant expressions in conditions (except for loops). + "no-constant-condition": ["error", { checkLoops: false }], + + // Disallow extending of native objects. + "no-extend-native": "error", + + // Disallow use of assignment in return statement. + "no-return-assign": ["error", "always"], + + // Disallow template literal placeholder syntax in regular strings. + "no-template-curly-in-string": "error", + + // Disallow unmodified loop conditions. + "no-unmodified-loop-condition": "error", + + // No expressions where a statement is expected + "no-unused-expressions": "error", + + // Require "use strict" to be defined globally in the script. + strict: ["error", "global"], + + // Disallow Yoda conditions. + yoda: ["error", "never"], + }, }, - rules: { - // Enforce return statements in callbacks of array methods. - "array-callback-return": "error", - - // Require default case in switch statements. - "default-case": "error", - - // Disallow use of alert(), confirm(), and prompt(). - "no-alert": "error", - - // Disallow likely erroneous `switch` scoped lexical declarations in - // case/default clauses. - "no-case-declarations": "error", - - // Disallow constant expressions in conditions (except for loops). - "no-constant-condition": ["error", { checkLoops: false }], - - // Disallow extending of native objects. - "no-extend-native": "error", - - // Disallow use of assignment in return statement. - "no-return-assign": ["error", "always"], - - // Disallow template literal placeholder syntax in regular strings. - "no-template-curly-in-string": "error", - - // Disallow unmodified loop conditions. - "no-unmodified-loop-condition": "error", - - // No expressions where a statement is expected - "no-unused-expressions": "error", - - // Require "use strict" to be defined globally in the script. - strict: ["error", "global"], - - // Disallow Yoda conditions. - yoda: ["error", "never"], - }, -}; +]; diff --git a/testing/mozbase/mozprofile/tests/files/dummy-profile/.eslintrc.mjs b/testing/mozbase/mozprofile/tests/files/dummy-profile/.eslintrc.mjs index 8d36cca28730..19158ec37ee6 100644 --- a/testing/mozbase/mozprofile/tests/files/dummy-profile/.eslintrc.mjs +++ b/testing/mozbase/mozprofile/tests/files/dummy-profile/.eslintrc.mjs @@ -1,7 +1,13 @@ -"use strict"; +/* 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/. */ -module.exports = { - globals: { - user_pref: true, +export default [ + { + languageOptions: { + globals: { + user_pref: true, + }, + }, }, -}; +]; diff --git a/testing/performance/.eslintrc.mjs b/testing/performance/.eslintrc.mjs index f04003250994..d9e5f7b93e98 100644 --- a/testing/performance/.eslintrc.mjs +++ b/testing/performance/.eslintrc.mjs @@ -2,11 +2,15 @@ * 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/. */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - browser: true, - node: true, +export default [ + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, }, -}; +]; diff --git a/testing/raptor/.eslintrc.mjs b/testing/raptor/.eslintrc.mjs index aaf8ae940c20..5ca582c1da51 100644 --- a/testing/raptor/.eslintrc.mjs +++ b/testing/raptor/.eslintrc.mjs @@ -2,23 +2,23 @@ * 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/. */ -"use strict"; +import globals from "globals"; +import mozilla from "eslint-plugin-mozilla"; -module.exports = { - env: { - webextensions: true, +export default [ + { + languageOptions: { + globals: { + ...globals.webextensions, + getTestConfig: false, + startMark: true, + endMark: true, + name: true, + }, + }, + plugins: { mozilla }, + rules: { + "mozilla/avoid-Date-timing": "error", + }, }, - - globals: { - getTestConfig: false, - startMark: true, - endMark: true, - name: true, - }, - - plugins: ["mozilla"], - - rules: { - "mozilla/avoid-Date-timing": "error", - }, -}; +]; diff --git a/testing/talos/.eslintrc.mjs b/testing/talos/.eslintrc.mjs index 8dd0a1c55988..4587b8684479 100644 --- a/testing/talos/.eslintrc.mjs +++ b/testing/talos/.eslintrc.mjs @@ -2,35 +2,38 @@ * 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/. */ -"use strict"; +import mozilla from "eslint-plugin-mozilla"; -module.exports = { - globals: { - Cc: false, - Ci: false, - Cu: false, - content: true, - dumpLog: false, - netscape: false, - addMessageListener: false, - goQuitApplication: false, - MozillaFileLogger: false, - Profiler: true, - Services: false, - gBrowser: false, - removeMessageListener: false, - sendAsyncMessage: false, - sendSyncMessage: false, - TalosPowersContent: true, - TalosPowersParent: true, - TalosContentProfiler: true, - TalosParentProfiler: true, - tpRecordTime: true, +export default [ + { + languageOptions: { + globals: { + Cc: false, + Ci: false, + Cu: false, + content: true, + dumpLog: false, + netscape: false, + addMessageListener: false, + goQuitApplication: false, + MozillaFileLogger: false, + Profiler: true, + Services: false, + gBrowser: false, + removeMessageListener: false, + sendAsyncMessage: false, + sendSyncMessage: false, + TalosPowersContent: true, + TalosPowersParent: true, + TalosContentProfiler: true, + TalosParentProfiler: true, + tpRecordTime: true, + }, + }, + plugins: { mozilla }, + + rules: { + "mozilla/avoid-Date-timing": "error", + }, }, - - plugins: ["mozilla"], - - rules: { - "mozilla/avoid-Date-timing": "error", - }, -}; +]; diff --git a/testing/talos/talos/tests/devtools/addon/content/.eslintrc.mjs b/testing/talos/talos/tests/devtools/addon/content/.eslintrc.mjs index 32aa87888e44..f9ad0bc47be4 100644 --- a/testing/talos/talos/tests/devtools/addon/content/.eslintrc.mjs +++ b/testing/talos/talos/tests/devtools/addon/content/.eslintrc.mjs @@ -1,26 +1,34 @@ -"use strict"; +/* 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/. */ -module.exports = { - plugins: ["react"], - globals: { - exports: true, - isWorker: true, - loader: true, - module: true, - reportError: true, - require: true, - dampWindow: true, - }, - rules: { - "no-unused-vars": ["error", { argsIgnorePattern: "^_", vars: "all" }], - // These are the rules that have been configured so far to match the - // devtools coding style. +import mozilla from "eslint-plugin-mozilla"; - // Rules from the mozilla plugin - "mozilla/no-aArgs": "error", - "mozilla/no-define-cc-etc": "off", - // See bug 1224289. - "mozilla/reject-importGlobalProperties": ["error", "everything"], - "mozilla/var-only-at-top-level": "error", +export default [ + { + plugins: { mozilla }, + languageOptions: { + globals: { + exports: true, + isWorker: true, + loader: true, + module: true, + reportError: true, + require: true, + dampWindow: true, + }, + }, + rules: { + "no-unused-vars": ["error", { argsIgnorePattern: "^_", vars: "all" }], + // These are the rules that have been configured so far to match the + // devtools coding style. + + // Rules from the mozilla plugin + "mozilla/no-aArgs": "error", + "mozilla/no-define-cc-etc": "off", + // See bug 1224289. + "mozilla/reject-importGlobalProperties": ["error", "everything"], + "mozilla/var-only-at-top-level": "error", + }, }, -}; +]; diff --git a/testing/talos/talos/tests/perf-reftest-singletons/.eslintrc.mjs b/testing/talos/talos/tests/perf-reftest-singletons/.eslintrc.mjs index 612b9ee56ebe..ece1a3f3b4ad 100644 --- a/testing/talos/talos/tests/perf-reftest-singletons/.eslintrc.mjs +++ b/testing/talos/talos/tests/perf-reftest-singletons/.eslintrc.mjs @@ -1,5 +1,11 @@ -{ - "rules": { - "no-undef": "off" - } -} +/* 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/. */ + +export default [ + { + rules: { + "no-undef": "off", + }, + }, +]; diff --git a/testing/talos/talos/tests/perf-reftest/.eslintrc.mjs b/testing/talos/talos/tests/perf-reftest/.eslintrc.mjs index 612b9ee56ebe..ece1a3f3b4ad 100644 --- a/testing/talos/talos/tests/perf-reftest/.eslintrc.mjs +++ b/testing/talos/talos/tests/perf-reftest/.eslintrc.mjs @@ -1,5 +1,11 @@ -{ - "rules": { - "no-undef": "off" - } -} +/* 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/. */ + +export default [ + { + rules: { + "no-undef": "off", + }, + }, +]; diff --git a/tools/lint/eslint/.eslintrc.mjs b/tools/lint/eslint/.eslintrc.mjs index 55b4784386a3..b631ba3eabfe 100644 --- a/tools/lint/eslint/.eslintrc.mjs +++ b/tools/lint/eslint/.eslintrc.mjs @@ -2,29 +2,38 @@ * 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/. */ -"use strict"; +import globals from "globals"; +import eslintPlugin from "eslint-plugin-eslint-plugin"; -module.exports = { - plugins: ["eslint-plugin"], - extends: ["plugin:eslint-plugin/recommended"], - // eslint-plugin-mozilla runs under node, so we need a more restrictive - // environment / parser setup here than the rest of mozilla-central. - env: { - browser: false, - node: true, - }, - parser: "espree", - parserOptions: { - // This should match with the minimum node version that the ESLint CI - // process uses (check the linux64-node toolchain). - ecmaVersion: 12, - }, +export default [ + { + ...eslintPlugin.configs["flat/recommended"], + languageOptions: { + globals: globals.node, + parserOptions: { + // This should match with the minimum node version that the ESLint CI + // process uses (check the linux64-node toolchain). + ecmaVersion: 12, + }, + }, - rules: { - camelcase: ["error", { properties: "never" }], - "handle-callback-err": ["error", "er"], - "no-undef-init": "error", - "one-var": ["error", "never"], - strict: ["error", "global"], + rules: { + camelcase: ["error", { properties: "never" }], + "handle-callback-err": ["error", "er"], + "no-undef-init": "error", + "one-var": ["error", "never"], + strict: ["error", "global"], + }, }, -}; + { + files: ["eslint-plugin-mozilla/scripts/createExports.js"], + languageOptions: { + sourceType: "script", + parserOptions: { + ecmaFeatures: { + globalReturn: true, + }, + }, + }, + }, +]; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.mjs b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.mjs index 76df4134f525..e5fdb99f8c2a 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.mjs +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.mjs @@ -1,8 +1,12 @@ -"use strict"; +/* 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/. */ -module.exports = { - rules: { - // Require object keys to be sorted. - "sort-keys": "error", +export default [ + { + rules: { + // Require object keys to be sorted. + "sort-keys": "error", + }, }, -}; +]; diff --git a/tools/lint/test/files/license/.eslintrc.mjs b/tools/lint/test/files/license/.eslintrc.mjs index 0449fdfa3338..50cb843f49e8 100644 --- a/tools/lint/test/files/license/.eslintrc.mjs +++ b/tools/lint/test/files/license/.eslintrc.mjs @@ -1,5 +1,3 @@ // Dot file to verify that it works // without license - -"use strict"; diff --git a/tools/tryselect/selectors/chooser/.eslintrc.mjs b/tools/tryselect/selectors/chooser/.eslintrc.mjs index 861d6bafc291..4eec8ed161b7 100644 --- a/tools/tryselect/selectors/chooser/.eslintrc.mjs +++ b/tools/tryselect/selectors/chooser/.eslintrc.mjs @@ -2,15 +2,17 @@ * 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/. */ -"use strict"; +import globals from "globals"; -module.exports = { - env: { - jquery: true, +export default [ + { + languageOptions: { + globals: { + ...globals.jquery, + apply: true, + applyChunks: true, + tasks: true, + }, + }, }, - globals: { - apply: true, - applyChunks: true, - tasks: true, - }, -}; +]; diff --git a/tools/ts/.eslintrc.mjs b/tools/ts/.eslintrc.mjs index a4a77efad7e3..ab03e7c91f10 100644 --- a/tools/ts/.eslintrc.mjs +++ b/tools/ts/.eslintrc.mjs @@ -2,17 +2,19 @@ * 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/. */ -"use strict"; +import eslintPlugin from "eslint-plugin-eslint-plugin"; +import globals from "globals"; -module.exports = { - plugins: ["eslint-plugin"], - extends: ["plugin:eslint-plugin/recommended"], - env: { - browser: false, - node: true, +export default [ + { + plugins: { "eslint-plugin": eslintPlugin }, + ...eslintPlugin.configs["flat/recommended"], + languageOptions: { + globals: { ...globals.browser, ...globals.node }, + }, + rules: { + "no-console": "off", + strict: ["error", "global"], + }, }, - rules: { - "no-console": "off", - strict: ["error", "global"], - }, -}; +];