diff --git a/toolkit/.eslintrc.mjs b/toolkit/.eslintrc.mjs index 3528c798313a..9f848356c69b 100644 --- a/toolkit/.eslintrc.mjs +++ b/toolkit/.eslintrc.mjs @@ -2,12 +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"; - -module.exports = { - rules: { - // XXX Bug 1326071 - This should be reduced down - probably to 20 or to - // be removed & synced with the mozilla/recommended value. - complexity: ["error", 45], +export default [ + { + rules: { + // XXX Bug 1326071 - This should be reduced down - probably to 20 or to + // be removed & synced with the mozilla/recommended value. + complexity: ["error", 45], + }, }, -}; +]; diff --git a/toolkit/components/antitracking/test/browser/.eslintrc.mjs b/toolkit/components/antitracking/test/browser/.eslintrc.mjs index e57058ecb1c4..1adc5097c67b 100644 --- a/toolkit/components/antitracking/test/browser/.eslintrc.mjs +++ b/toolkit/components/antitracking/test/browser/.eslintrc.mjs @@ -1,7 +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 = { - env: { - webextensions: true, - }, -}; +import globals from "globals"; + +export default [{ languageOptions: { globals: globals.webextensions } }]; diff --git a/toolkit/components/extensions/.eslintrc.mjs b/toolkit/components/extensions/.eslintrc.mjs index fcb18593fc1e..d74b4f68b544 100644 --- a/toolkit/components/extensions/.eslintrc.mjs +++ b/toolkit/components/extensions/.eslintrc.mjs @@ -2,211 +2,208 @@ * 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: { + // Rules from the mozilla plugin + "mozilla/balanced-listeners": "error", + "mozilla/no-aArgs": "error", + "mozilla/var-only-at-top-level": "error", + // Disable reject-importGlobalProperties because we don't want to include + // these in the sandbox directly as that would potentially mean the + // imported properties would be instatiated up-front rather than lazily. + "mozilla/reject-importGlobalProperties": "off", -module.exports = { - rules: { - // Rules from the mozilla plugin - "mozilla/balanced-listeners": "error", - "mozilla/no-aArgs": "error", - "mozilla/var-only-at-top-level": "error", - // Disable reject-importGlobalProperties because we don't want to include - // these in the sandbox directly as that would potentially mean the - // imported properties would be instatiated up-front rather than lazily. - "mozilla/reject-importGlobalProperties": "off", + // Functions are not required to consistently return something or nothing + "consistent-return": "off", - // Functions are not required to consistently return something or nothing - "consistent-return": "off", + // Disallow empty statements. This will report an error for: + // try { something(); } catch (e) {} + // but will not report it for: + // try { something(); } catch (e) { /* Silencing the error because ...*/ } + // which is a valid use case. + "no-empty": "error", - // Disallow empty statements. This will report an error for: - // try { something(); } catch (e) {} - // but will not report it for: - // try { something(); } catch (e) { /* Silencing the error because ...*/ } - // which is a valid use case. - "no-empty": "error", + // 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", + { + argsIgnorePattern: "^_", + vars: "all", + varsIgnorePattern: "^console$", + }, + ], - // No declaring variables that are never used - "no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - vars: "all", - varsIgnorePattern: "^console$", - }, - ], + // No using things before they're defined. + "no-use-before-define": [ + "error", + { + allowNamedExports: true, + classes: true, + // The next two being false allows idiomatic patterns which are more + // type-inference friendly. Functions are hoisted, so this is safe. + functions: false, + // This flag is only meaningful for `var` declarations. + // When false, it still disallows use-before-define in the same scope. + // Since we only allow `var` at the global scope, this is no worse than + // how we currently declare an uninitialized `let` at the top of file. + variables: false, + }, + ], - // No using things before they're defined. - "no-use-before-define": [ - "error", - { - allowNamedExports: true, - classes: true, - // The next two being false allows idiomatic patterns which are more - // type-inference friendly. Functions are hoisted, so this is safe. - functions: false, - // This flag is only meaningful for `var` declarations. - // When false, it still disallows use-before-define in the same scope. - // Since we only allow `var` at the global scope, this is no worse than - // how we currently declare an uninitialized `let` at the top of file. - variables: false, - }, - ], + // 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", - // Warn about cyclomatic complexity in functions. - complexity: "error", + // Don't warn for inconsistent naming when capturing this (not so important + // with auto-binding fat arrow functions). + // "consistent-this": ["error", "self"], - // Don't warn for inconsistent naming when capturing this (not so important - // with auto-binding fat arrow functions). - // "consistent-this": ["error", "self"], + // Don't require a default case in switch statements. Avoid being forced to + // add a bogus default when you know all possible cases are handled. + "default-case": "off", - // Don't require a default case in switch statements. Avoid being forced to - // add a bogus default when you know all possible cases are handled. - "default-case": "off", + // Allow using == instead of ===, in the interest of landing something since + // the devtools codebase is split on convention here. + eqeqeq: "off", - // Allow using == instead of ===, in the interest of landing something since - // the devtools codebase is split on convention here. - eqeqeq: "off", + // Don't require function expressions to have a name. + // This makes the code more verbose and hard to read. Our engine already + // does a fantastic job assigning a name to the function, which includes + // the enclosing function name, and worst case you have a line number that + // you can just look up. + "func-names": "off", - // Don't require function expressions to have a name. - // This makes the code more verbose and hard to read. Our engine already - // does a fantastic job assigning a name to the function, which includes - // the enclosing function name, and worst case you have a line number that - // you can just look up. - "func-names": "off", + // Allow use of function declarations and expressions. + "func-style": "off", - // Allow use of function declarations and expressions. - "func-style": "off", + // Maximum depth callbacks can be nested. + "max-nested-callbacks": ["error", 4], - // Maximum depth callbacks can be nested. - "max-nested-callbacks": ["error", 4], + // Don't limit the number of parameters that can be used in a function. + "max-params": "off", - // Don't limit the number of parameters that can be used in a function. - "max-params": "off", + // Don't limit the maximum number of statement allowed in a function. We + // already have the complexity rule that's a better measurement. + "max-statements": "off", - // Don't limit the maximum number of statement allowed in a function. We - // already have the complexity rule that's a better measurement. - "max-statements": "off", + // Don't require a capital letter for constructors, only check if all new + // operators are followed by a capital letter. Don't warn when capitalized + // functions are used without the new operator. + "new-cap": ["off", { capIsNew: false }], - // Don't require a capital letter for constructors, only check if all new - // operators are followed by a capital letter. Don't warn when capitalized - // functions are used without the new operator. - "new-cap": ["off", { capIsNew: false }], + // Allow use of bitwise operators. + "no-bitwise": "off", - // Allow use of bitwise operators. - "no-bitwise": "off", + // Allow use of the continue statement. + "no-continue": "off", - // Allow use of the continue statement. - "no-continue": "off", + // Allow division operators explicitly at beginning of regular expression. + "no-div-regex": "off", - // Allow division operators explicitly at beginning of regular expression. - "no-div-regex": "off", + // Disallow adding to native types + "no-extend-native": "error", - // Disallow adding to native types - "no-extend-native": "error", + // Allow comments inline after code. + "no-inline-comments": "off", - // Allow comments inline after code. - "no-inline-comments": "off", + // Disallow use of labels for anything other then loops and switches. + "no-labels": ["error", { allowLoop: true }], - // Disallow use of labels for anything other then loops and switches. - "no-labels": ["error", { allowLoop: true }], + // 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", + // Allow reassignment of function parameters. + "no-param-reassign": "off", - // Allow reassignment of function parameters. - "no-param-reassign": "off", + // Allow string concatenation with __dirname and __filename (not a node env). + "no-path-concat": "off", - // Allow string concatenation with __dirname and __filename (not a node env). - "no-path-concat": "off", + // Allow use of unary operators, ++ and --. + "no-plusplus": "off", - // Allow use of unary operators, ++ and --. - "no-plusplus": "off", + // Allow using process.env (not a node environment). + "no-process-env": "off", - // Allow using process.env (not a node environment). - "no-process-env": "off", + // Allow using process.exit (not a node environment). + "no-process-exit": "off", - // Allow using process.exit (not a node environment). - "no-process-exit": "off", + // Disallow usage of __proto__ property. + "no-proto": "error", - // Disallow usage of __proto__ property. - "no-proto": "error", + // Don't restrict usage of specified node modules (not a node environment). + "no-restricted-modules": "off", - // Don't restrict usage of specified node modules (not a node environment). - "no-restricted-modules": "off", + // 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", + // Allow use of synchronous methods (not a node environment). + "no-sync": "off", - // Allow use of synchronous methods (not a node environment). - "no-sync": "off", + // Allow the use of ternary operators. + "no-ternary": "off", - // Allow the use of ternary operators. - "no-ternary": "off", + // Allow dangling underscores in identifiers (for privates). + "no-underscore-dangle": "off", - // Allow dangling underscores in identifiers (for privates). - "no-underscore-dangle": "off", + // Allow use of undefined variable. + "no-undefined": "off", - // Allow use of undefined variable. - "no-undefined": "off", + // We use var-only-at-top-level instead of no-var as we allow top level + // vars. + "no-var": "off", - // We use var-only-at-top-level instead of no-var as we allow top level - // vars. - "no-var": "off", + // Allow using TODO/FIXME comments. + "no-warning-comments": "off", - // Allow using TODO/FIXME comments. - "no-warning-comments": "off", + // Don't require method and property shorthand syntax for object literals. + // We use this in the code a lot, but not consistently, and this seems more + // like something to check at code review time. + "object-shorthand": "off", - // Don't require method and property shorthand syntax for object literals. - // We use this in the code a lot, but not consistently, and this seems more - // like something to check at code review time. - "object-shorthand": "off", + // Allow more than one variable declaration per function. + "one-var": "off", - // Allow more than one variable declaration per function. - "one-var": "off", + // Require use of the second argument for parseInt(). + radix: "error", - // Require use of the second argument for parseInt(). - radix: "error", + // Don't require to sort variables within the same declaration block. + // Anyway, one-var is disabled. + "sort-vars": "off", - // Don't require to sort variables within the same declaration block. - // Anyway, one-var is disabled. - "sort-vars": "off", + // 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"], + // Allow vars to be declared anywhere in the scope. + "vars-on-top": "off", - // Allow vars to be declared anywhere in the scope. - "vars-on-top": "off", + // 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", - - // Disallow labels that share a name with a variable - "no-label-var": "error", - }, - - overrides: [ - { - files: "test/xpcshell/head*.js", - rules: { - "no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - vars: "local", - }, - ], - }, + // Disallow labels that share a name with a variable + "no-label-var": "error", }, - ], -}; + }, + { + files: "test/xpcshell/head*.js", + rules: { + "no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + vars: "local", + }, + ], + }, + }, +]; diff --git a/toolkit/components/extensions/child/.eslintrc.mjs b/toolkit/components/extensions/child/.eslintrc.mjs index 1822d107d2bb..9f1c74f4abd3 100644 --- a/toolkit/components/extensions/child/.eslintrc.mjs +++ b/toolkit/components/extensions/child/.eslintrc.mjs @@ -2,39 +2,41 @@ * 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: { + // These are defined in the WebExtension script scopes by + // ExtensionCommon.sys.mjs in the _createExtGlobal method. + AppConstants: true, + Cc: true, + ChromeWorker: true, + Ci: true, + Cr: true, + Cu: true, + ExtensionAPI: true, + ExtensionAPIPersistent: true, + ExtensionCommon: true, + FileReader: true, + Glean: true, + GleanPings: true, + IOUtils: true, + MatchGlob: true, + MatchPattern: true, + MatchPatternSet: true, + OffscreenCanvas: true, + PathUtils: true, + Services: true, + StructuredCloneHolder: true, + WebExtensionPolicy: true, + XPCOMUtils: true, + extensions: true, + global: true, + ExtensionUtils: true, -module.exports = { - globals: { - // These are defined in the WebExtension script scopes by - // ExtensionCommon.sys.mjs in the _createExtGlobal method. - AppConstants: true, - Cc: true, - ChromeWorker: true, - Ci: true, - Cr: true, - Cu: true, - ExtensionAPI: true, - ExtensionAPIPersistent: true, - ExtensionCommon: true, - FileReader: true, - Glean: true, - GleanPings: true, - IOUtils: true, - MatchGlob: true, - MatchPattern: true, - MatchPatternSet: true, - OffscreenCanvas: true, - PathUtils: true, - Services: true, - StructuredCloneHolder: true, - WebExtensionPolicy: true, - XPCOMUtils: true, - extensions: true, - global: true, - ExtensionUtils: true, - - // This is defined in toolkit/components/extensions/child/ext-toolkit.js - EventManager: true, + // This is defined in toolkit/components/extensions/child/ext-toolkit.js + EventManager: true, + }, + }, }, -}; +]; diff --git a/toolkit/components/extensions/parent/.eslintrc.mjs b/toolkit/components/extensions/parent/.eslintrc.mjs index 4d6ecb3431fd..72463a6b2f7e 100644 --- a/toolkit/components/extensions/parent/.eslintrc.mjs +++ b/toolkit/components/extensions/parent/.eslintrc.mjs @@ -2,60 +2,62 @@ * 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: { + // These are defined in the WebExtension script scopes by + // ExtensionCommon.sys.mjs in the _createExtGlobal method. + AppConstants: true, + Cc: true, + ChromeWorker: true, + Ci: true, + Cr: true, + Cu: true, + ExtensionAPI: true, + ExtensionAPIPersistent: true, + ExtensionCommon: true, + FileReader: true, + Glean: true, + GleanPings: true, + IOUtils: true, + MatchGlob: true, + MatchPattern: true, + MatchPatternSet: true, + OffscreenCanvas: true, + PathUtils: true, + Services: true, + StructuredCloneHolder: true, + WebExtensionPolicy: true, + XPCOMUtils: true, + extensions: true, + global: true, + ExtensionUtils: true, -module.exports = { - globals: { - // These are defined in the WebExtension script scopes by - // ExtensionCommon.sys.mjs in the _createExtGlobal method. - AppConstants: true, - Cc: true, - ChromeWorker: true, - Ci: true, - Cr: true, - Cu: true, - ExtensionAPI: true, - ExtensionAPIPersistent: true, - ExtensionCommon: true, - FileReader: true, - Glean: true, - GleanPings: true, - IOUtils: true, - MatchGlob: true, - MatchPattern: true, - MatchPatternSet: true, - OffscreenCanvas: true, - PathUtils: true, - Services: true, - StructuredCloneHolder: true, - WebExtensionPolicy: true, - XPCOMUtils: true, - extensions: true, - global: true, - ExtensionUtils: true, - - // These are defined in toolkit/components/extensions/parent/ext-tabs-base.js - TabBase: true, - TabManagerBase: true, - TabTrackerBase: true, - WindowBase: true, - WindowManagerBase: true, - WindowTrackerBase: true, - getUserContextIdForCookieStoreId: true, - // There are defined in toolkit/components/extensions/parent/ext-toolkit.js - CONTAINER_STORE: true, - DEFAULT_STORE: true, - EventEmitter: true, - EventManager: true, - PRIVATE_STORE: true, - getContainerForCookieStoreId: true, - getCookieStoreIdForContainer: true, - getCookieStoreIdForOriginAttributes: true, - getCookieStoreIdForTab: true, - getOriginAttributesPatternForCookieStoreId: true, - isContainerCookieStoreId: true, - isDefaultCookieStoreId: true, - isPrivateCookieStoreId: true, - isValidCookieStoreId: true, + // These are defined in toolkit/components/extensions/parent/ext-tabs-base.js + TabBase: true, + TabManagerBase: true, + TabTrackerBase: true, + WindowBase: true, + WindowManagerBase: true, + WindowTrackerBase: true, + getUserContextIdForCookieStoreId: true, + // There are defined in toolkit/components/extensions/parent/ext-toolkit.js + CONTAINER_STORE: true, + DEFAULT_STORE: true, + EventEmitter: true, + EventManager: true, + PRIVATE_STORE: true, + getContainerForCookieStoreId: true, + getCookieStoreIdForContainer: true, + getCookieStoreIdForOriginAttributes: true, + getCookieStoreIdForTab: true, + getOriginAttributesPatternForCookieStoreId: true, + isContainerCookieStoreId: true, + isDefaultCookieStoreId: true, + isPrivateCookieStoreId: true, + isValidCookieStoreId: true, + }, + }, }, -}; +]; diff --git a/toolkit/components/extensions/test/browser/.eslintrc.mjs b/toolkit/components/extensions/test/browser/.eslintrc.mjs index e57058ecb1c4..f2258348a771 100644 --- a/toolkit/components/extensions/test/browser/.eslintrc.mjs +++ b/toolkit/components/extensions/test/browser/.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 = { - env: { - webextensions: true, +import globals from "globals"; + +export default [ + { + languageOptions: { + globals: globals.webextensions, + }, }, -}; +]; diff --git a/toolkit/components/extensions/test/mochitest/.eslintrc.mjs b/toolkit/components/extensions/test/mochitest/.eslintrc.mjs index 7802d13962f3..f2258348a771 100644 --- a/toolkit/components/extensions/test/mochitest/.eslintrc.mjs +++ b/toolkit/components/extensions/test/mochitest/.eslintrc.mjs @@ -1,8 +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 = { - env: { - browser: true, - webextensions: true, +import globals from "globals"; + +export default [ + { + languageOptions: { + globals: globals.webextensions, + }, }, -}; +]; diff --git a/toolkit/components/extensions/test/xpcshell/.eslintrc.mjs b/toolkit/components/extensions/test/xpcshell/.eslintrc.mjs index 60d784b53c11..481079f431a5 100644 --- a/toolkit/components/extensions/test/xpcshell/.eslintrc.mjs +++ b/toolkit/components/extensions/test/xpcshell/.eslintrc.mjs @@ -1,13 +1,21 @@ -"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: { - // The tests in this folder are testing based on WebExtensions, so lets - // just define the webextensions environment here. - webextensions: true, - // Many parts of WebExtensions test definitions (e.g. content scripts) also - // interact with the browser environment, so define that here as we don't - // have an easy way to handle per-function/scope usage yet. - browser: true, +import globals from "globals"; + +export default [ + { + languageOptions: { + globals: { + // The tests in this folder are testing based on WebExtensions, so lets + // just define the webextensions environment here. + ...globals.webextensions, + // Many parts of WebExtensions test definitions (e.g. content scripts) also + // interact with the browser environment, so define that here as we don't + // have an easy way to handle per-function/scope usage yet. + ...globals.browser, + }, + }, }, -}; +]; diff --git a/toolkit/components/extensions/test/xpcshell/webidl-api/.eslintrc.mjs b/toolkit/components/extensions/test/xpcshell/webidl-api/.eslintrc.mjs index 3622fff4f6a2..c9d370a50043 100644 --- a/toolkit/components/extensions/test/xpcshell/webidl-api/.eslintrc.mjs +++ b/toolkit/components/extensions/test/xpcshell/webidl-api/.eslintrc.mjs @@ -1,9 +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 = { - env: { - // The tests in this folder are testing based on WebExtensions, so lets - // just define the webextensions environment here. - webextensions: true, +import globals from "globals"; + +export default [ + { + languageOptions: { + // The tests in this folder are testing based on WebExtensions, so lets + // just define the webextensions environment here. + globals: globals.webextensions, + }, }, -}; +]; diff --git a/toolkit/components/narrate/.eslintrc.mjs b/toolkit/components/narrate/.eslintrc.mjs index 241d12a0dd0c..bf71894a5679 100644 --- a/toolkit/components/narrate/.eslintrc.mjs +++ b/toolkit/components/narrate/.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"; - -module.exports = { - 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", { max: 20 }], - "max-nested-callbacks": ["error", 3], - "new-cap": ["error", { capIsNew: false }], - "no-extend-native": "error", - "no-inline-comments": "error", - "no-multi-str": "error", - "no-return-assign": "error", - strict: ["error", "global"], - yoda: "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", { max: 20 }], + "max-nested-callbacks": ["error", 3], + "new-cap": ["error", { capIsNew: false }], + "no-extend-native": "error", + "no-inline-comments": "error", + "no-multi-str": "error", + "no-return-assign": "error", + strict: ["error", "global"], + yoda: "error", + }, }, -}; +]; diff --git a/toolkit/components/normandy/test/.eslintrc.mjs b/toolkit/components/normandy/test/.eslintrc.mjs index 0ee96759d4fa..2126a2d04cef 100644 --- a/toolkit/components/normandy/test/.eslintrc.mjs +++ b/toolkit/components/normandy/test/.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: { - "require-yield": 0, +export default [ + { + rules: { + "require-yield": 0, + }, }, -}; +]; diff --git a/toolkit/components/passwordmgr/test/browser/.eslintrc.mjs b/toolkit/components/passwordmgr/test/browser/.eslintrc.mjs index 000a981cbef9..f5acf4543741 100644 --- a/toolkit/components/passwordmgr/test/browser/.eslintrc.mjs +++ b/toolkit/components/passwordmgr/test/browser/.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: { - "no-var": "off", +export default [ + { + rules: { + "no-var": "off", + }, }, -}; +]; diff --git a/toolkit/components/passwordmgr/test/mochitest/.eslintrc.mjs b/toolkit/components/passwordmgr/test/mochitest/.eslintrc.mjs index beb8ec4738f1..afa40d3dd603 100644 --- a/toolkit/components/passwordmgr/test/mochitest/.eslintrc.mjs +++ b/toolkit/components/passwordmgr/test/mochitest/.eslintrc.mjs @@ -1,17 +1,23 @@ -"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: { - promptDone: true, - startTest: true, - // Make no-undef happy with our runInParent mixed environments since you - // can't indicate a single function is a new env. - assert: true, - addMessageListener: true, - sendAsyncMessage: true, - Assert: true, +export default [ + { + languageOptions: { + globals: { + promptDone: true, + startTest: true, + // Make no-undef happy with our runInParent mixed environments since you + // can't indicate a single function is a new env. + assert: true, + addMessageListener: true, + sendAsyncMessage: true, + Assert: true, + }, + }, + rules: { + "no-var": "off", + }, }, - rules: { - "no-var": "off", - }, -}; +]; diff --git a/toolkit/components/prompts/test/.eslintrc.mjs b/toolkit/components/prompts/test/.eslintrc.mjs index af973e82fe1d..19e5122cac32 100644 --- a/toolkit/components/prompts/test/.eslintrc.mjs +++ b/toolkit/components/prompts/test/.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: { - // ownerGlobal doesn't exist in content privileged windows. - "mozilla/use-ownerGlobal": "off", +export default [ + { + rules: { + // ownerGlobal doesn't exist in content privileged windows. + "mozilla/use-ownerGlobal": "off", + }, }, -}; +]; diff --git a/toolkit/components/reader/.eslintrc.mjs b/toolkit/components/reader/.eslintrc.mjs index fa17d2bb686e..7adcdc6984be 100644 --- a/toolkit/components/reader/.eslintrc.mjs +++ b/toolkit/components/reader/.eslintrc.mjs @@ -2,11 +2,11 @@ * 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 = { - rules: { - "no-inner-declarations": "error", - "no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }], +export default [ + { + rules: { + "no-inner-declarations": "error", + "no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }], + }, }, -}; +]; diff --git a/toolkit/content/.eslintrc.mjs b/toolkit/content/.eslintrc.mjs index b56cafb08b90..1f82689660eb 100644 --- a/toolkit/content/.eslintrc.mjs +++ b/toolkit/content/.eslintrc.mjs @@ -2,23 +2,21 @@ * 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 = { - overrides: [ - { - files: "./**/*.?(m)js", - excludedFiles: "aboutwebrtc/**", - env: { - "mozilla/browser-window": true, - }, +export default [ + { + rules: { + // XXX Bug 1358949 - This should be reduced down - probably to 20 or to + // be removed & synced with the mozilla/recommended value. + complexity: ["error", 48], }, - ], - plugins: ["mozilla"], - - rules: { - // XXX Bug 1358949 - This should be reduced down - probably to 20 or to - // be removed & synced with the mozilla/recommended value. - complexity: ["error", 48], }, -}; + { + files: ["**/*.?(m)js"], + ignores: ["aboutwebrtc/**"], + languageOptions: { + globals: mozilla.environments["browser-window"].globals, + }, + }, +]; diff --git a/toolkit/modules/subprocess/.eslintrc.mjs b/toolkit/modules/subprocess/.eslintrc.mjs index ccec3c9d1bc8..fb7edd1ddcb7 100644 --- a/toolkit/modules/subprocess/.eslintrc.mjs +++ b/toolkit/modules/subprocess/.eslintrc.mjs @@ -2,8 +2,6 @@ * 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 extensionsConfig from "../../components/extensions/.eslintrc.mjs"; -module.exports = { - extends: "../../components/extensions/.eslintrc.js", -}; +export default [...extensionsConfig]; diff --git a/toolkit/mozapps/extensions/.eslintrc.mjs b/toolkit/mozapps/extensions/.eslintrc.mjs index ef31f0780e9b..d7508b307264 100644 --- a/toolkit/mozapps/extensions/.eslintrc.mjs +++ b/toolkit/mozapps/extensions/.eslintrc.mjs @@ -2,35 +2,33 @@ * 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: { + // Warn about cyclomatic complexity in functions. + // XXX Bug 1326071 - This should be reduced down - probably to 20 or to + // be removed & synced with the mozilla/recommended value. + complexity: ["error", { max: 68 }], -module.exports = { - rules: { - // Warn about cyclomatic complexity in functions. - // XXX Bug 1326071 - This should be reduced down - probably to 20 or to - // be removed & synced with the mozilla/recommended value. - complexity: ["error", { max: 68 }], - - "no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - vars: "all", - }, - ], - }, - overrides: [ - { - files: "test/xpcshell/head*.js", - rules: { - "no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - vars: "local", - }, - ], - }, + "no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + vars: "all", + }, + ], }, - ], -}; + }, + { + files: "test/xpcshell/head*.js", + rules: { + "no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + vars: "local", + }, + ], + }, + }, +]; diff --git a/toolkit/mozapps/extensions/test/browser/.eslintrc.mjs b/toolkit/mozapps/extensions/test/browser/.eslintrc.mjs index 6987757bdcd2..937e6007ac4b 100644 --- a/toolkit/mozapps/extensions/test/browser/.eslintrc.mjs +++ b/toolkit/mozapps/extensions/test/browser/.eslintrc.mjs @@ -1,14 +1,18 @@ -"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"; - rules: { - "no-unused-vars": [ - "error", - { argsIgnorePattern: "^_", varsIgnorePattern: "^end_test$" }, - ], +export default [ + { + languageOptions: { globals: globals.webextensions }, + + rules: { + "no-unused-vars": [ + "error", + { argsIgnorePattern: "^_", varsIgnorePattern: "^end_test$" }, + ], + }, }, -}; +]; diff --git a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.mjs b/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.mjs index 26a3e6177f5d..55dd0d755c71 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.mjs +++ b/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.mjs @@ -1,24 +1,26 @@ -"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: { - "no-unused-vars": [ - "error", - { argsIgnorePattern: "^_", varsIgnorePattern: "^end_test$" }, - ], - }, - overrides: [ - { - files: "head*.js", - rules: { - "no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - vars: "local", - }, - ], - }, +export default [ + { + rules: { + "no-unused-vars": [ + "error", + { argsIgnorePattern: "^_", varsIgnorePattern: "^end_test$" }, + ], }, - ], -}; + }, + { + files: "**/head*.js", + rules: { + "no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + vars: "local", + }, + ], + }, + }, +];