new file mode 100644
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js
@@ -0,0 +1,8 @@
+"use strict";
+
+module.exports = {
+ "rules": {
+ // Require object keys to be sorted.
+ "sort-keys": "error"
+ }
+};
\ No newline at end of file
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js
@@ -1,66 +1,66 @@
// Parent config file for all browser-chrome files.
"use strict";
module.exports = {
- "rules": {
- "mozilla/import-content-task-globals": "error",
- "mozilla/import-headjs-globals": "warn",
- "mozilla/mark-test-function-used": "warn"
- },
-
"env": {
"browser": true,
"mozilla/browser-window": true,
"mozilla/simpletest": true
// "node": true
},
- "plugins": [
- "mozilla"
- ],
-
// All globals made available in the test environment.
"globals": {
// `$` is defined in SimpleTest.js
"$": false,
- "add_task": false,
- "addLoadEvent": false,
"Assert": false,
"BrowserTestUtils": false,
- "content": false,
"ContentTask": false,
"ContentTaskUtils": false,
"EventUtils": false,
+ "PromiseDebugging": false,
+ "SpecialPowers": false,
+ "TestUtils": false,
+ "XPCNativeWrapper": false,
+ "XULDocument": false,
+ "addLoadEvent": false,
+ "add_task": false,
+ "content": false,
"executeSoon": false,
"expectUncaughtException": false,
"export_assertions": false,
"extractJarToTmp": false,
"finish": false,
+ "gTestPath": false,
"getChromeDir": false,
"getJar": false,
"getResolvedURI": false,
"getRootDirectory": false,
"getTestFilePath": false,
- "gTestPath": false,
+ "ignoreAllUncaughtExceptions": false,
"info": false,
- "ignoreAllUncaughtExceptions": false,
"is": false,
"isnot": false,
"ok": false,
- "PromiseDebugging": false,
"privateNoteIntentionalCrash": false,
"registerCleanupFunction": false,
"requestLongerTimeout": false,
- "SpecialPowers": false,
- "TestUtils": false,
"thisTestLeaksUncaughtRejectionsAndShouldBeFixed": false,
"todo": false,
"todo_is": false,
"todo_isnot": false,
"waitForClipboard": false,
"waitForExplicitFinish": false,
- "waitForFocus": false,
- "XPCNativeWrapper": false,
- "XULDocument": false
+ "waitForFocus": false
+ },
+
+ "plugins": [
+ "mozilla"
+ ],
+
+ "rules": {
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "warn",
+ "mozilla/mark-test-function-used": "warn"
}
};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js
@@ -1,55 +1,55 @@
// Parent config file for all mochitest files.
"use strict";
module.exports = {
- rules: {
- "mozilla/import-content-task-globals": "error",
- "mozilla/import-headjs-globals": "warn",
- "mozilla/mark-test-function-used": "warn"
- },
-
"env": {
"browser": true,
"mozilla/browser-window": true,
"mozilla/simpletest": true
},
- "plugins": [
- "mozilla"
- ],
-
// All globals made available in the test environment.
"globals": {
// `$` is defined in SimpleTest.js
"$": false,
- "add_task": false,
- "addLoadEvent": false,
"Assert": false,
"BrowserTestUtils": false,
"ContentTask": false,
"EventUtils": false,
+ "SpecialPowers": false,
+ "addLoadEvent": false,
+ "add_task": false,
"executeSoon": false,
"export_assertions": false,
"extractJarToTmp": false,
"finish": false,
+ "gTestPath": false,
"getJar": false,
"getRootDirectory": false,
"getTestFilePath": false,
- "gTestPath": false,
"info": false,
"is": false,
"isnot": false,
"ok": false,
"privateNoteIntentionalCrash": false,
"promise": false,
"registerCleanupFunction": false,
"requestLongerTimeout": false,
- "SpecialPowers": false,
"todo": false,
"todo_is": false,
"todo_isnot": false,
"waitForClipboard": false,
"waitForExplicitFinish": false,
"waitForFocus": false
+ },
+
+ "plugins": [
+ "mozilla"
+ ],
+
+ rules: {
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "warn",
+ "mozilla/mark-test-function-used": "warn"
}
};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
@@ -1,52 +1,52 @@
// Parent config file for all mochitest files.
"use strict";
module.exports = {
- "rules": {
- "mozilla/import-content-task-globals": "error",
- "mozilla/import-headjs-globals": "warn",
- "mozilla/mark-test-function-used": "warn",
- "no-shadow": "error"
- },
-
"env": {
"browser": true,
"mozilla/simpletest": true
},
- "plugins": [
- "mozilla"
- ],
-
// All globals made available in the test environment.
"globals": {
// `$` is defined in SimpleTest.js
"$": false,
- "add_task": false,
- "addLoadEvent": false,
"Assert": false,
"EventUtils": false,
+ "SpecialPowers": false,
+ "addLoadEvent": false,
+ "add_task": false,
"executeSoon": false,
"export_assertions": false,
"finish": false,
+ "gTestPath": false,
"getRootDirectory": false,
"getTestFilePath": false,
- "gTestPath": false,
"info": false,
"is": false,
"isDeeply": false,
"isnot": false,
"netscape": false,
"ok": false,
"promise": false,
"registerCleanupFunction": false,
"requestLongerTimeout": false,
- "SpecialPowers": false,
"todo": false,
"todo_is": false,
"todo_isnot": false,
"waitForClipboard": false,
"waitForExplicitFinish": false,
"waitForFocus": false
+ },
+
+ "plugins": [
+ "mozilla"
+ ],
+
+ "rules": {
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "warn",
+ "mozilla/mark-test-function-used": "warn",
+ "no-shadow": "error"
}
};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -1,49 +1,77 @@
"use strict";
module.exports = {
- // When adding items to this file please check for effects on sub-directories.
- "plugins": [
- "mozilla"
- ],
"env": {
"browser": true,
"es6": true
},
+
+ "globals": {
+ "BroadcastChannel": false,
+ "CSSPrimitiveValue": false,
+ "CSSValueList": false,
+ // Specific to Firefox (Chrome code only).
+ "ChromeUtils": false,
+ "ChromeWindow": false,
+ "ChromeWorker": false,
+ "Components": false,
+ "ImageDocument": false,
+ "InstallTrigger": false,
+ // Specific to Firefox
+ // eslint-disable-next-line max-len
+ // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
+ "InternalError": true,
+ "KeyEvent": false,
+ "MenuBoxObject": false,
+ // Specific to Firefox (Chrome code only).
+ "MozSelfSupport": false,
+ "SharedArrayBuffer": false,
+ "SimpleGestureEvent": false,
+ // Note: StopIteration will likely be removed as part of removing legacy
+ // generators, see bug 968038.
+ "StopIteration": false,
+ // Non-standard, specific to Firefox.
+ "XULElement": false,
+ "dump": true,
+ "openDialog": false,
+ "sizeToContent": false,
+ // Specific to Firefox
+ // eslint-disable-next-line max-len
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
+ "uneval": false
+ },
+
"parserOptions": {
"ecmaVersion": 8
},
+
+ // When adding items to this file please check for effects on sub-directories.
+ "plugins": [
+ "mozilla"
+ ],
+
// When adding items to this file please check for effects on all of toolkit
// and browser
"rules": {
- "mozilla/avoid-removeChild": "error",
- "mozilla/avoid-nsISupportsString-preferences": "error",
- "mozilla/import-browser-window-globals": "error",
- "mozilla/import-globals": "error",
- "mozilla/no-import-into-var-and-global": "error",
- "mozilla/no-useless-parameters": "error",
- "mozilla/no-useless-removeEventListener": "error",
- "mozilla/use-default-preference-values": "error",
- "mozilla/use-ownerGlobal": "error",
+ // Require spacing around =>
+ "arrow-spacing": "error",
// Braces only needed for multi-line arrow function blocks
- // "arrow-body-style": ["error", "as-needed"],
-
- // Require spacing around =>
- "arrow-spacing": "error",
+ // "arrow-body-style": ["error", "as-needed"]
// Always require spacing around a single line block
"block-spacing": "error",
// No newline before open brace for a block
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
// No space before always a space after a comma
- "comma-spacing": ["error", {"before": false, "after": true}],
+ "comma-spacing": ["error", {"after": true, "before": false}],
// Commas at the end of the line not the start
// "comma-style": "error",
// Warn about cyclomatic complexity in functions.
// XXX Get this down to 20?
"complexity": ["error", 32],
@@ -67,34 +95,44 @@ module.exports = {
// Require function* name()
// "generator-star-spacing": ["error", {"before": false, "after": true}],
// Two space indent
// "indent": ["error", 2, { "SwitchCase": 1 }],
// Space after colon not before in property declarations
"key-spacing": ["error", {
+ "afterColon": true,
"beforeColon": false,
- "afterColon": true,
"mode": "minimum"
}],
// Require spaces before and after keywords
"keyword-spacing": "error",
// Unix linebreaks
"linebreak-style": ["error", "unix"],
// Don't enforce the maximum depth that blocks can be nested. The complexity
// rule is a better rule to check this.
"max-depth": "off",
// Maximum depth callbacks can be nested.
"max-nested-callbacks": ["error", 10],
+ "mozilla/avoid-nsISupportsString-preferences": "error",
+ "mozilla/avoid-removeChild": "error",
+ "mozilla/import-browser-window-globals": "error",
+ "mozilla/import-globals": "error",
+ "mozilla/no-import-into-var-and-global": "error",
+ "mozilla/no-useless-parameters": "error",
+ "mozilla/no-useless-removeEventListener": "error",
+ "mozilla/use-default-preference-values": "error",
+ "mozilla/use-ownerGlobal": "error",
+
// Always require parenthesis for new calls
// "new-parens": "error",
// Use [] instead of Array()
// "no-array-constructor": "error",
// Disallow assignment operators in conditional statements
"no-cond-assign": "error",
@@ -109,74 +147,76 @@ module.exports = {
"no-dupe-args": "error",
// No duplicate keys in object declarations
"no-dupe-keys": "error",
// No duplicate cases in switch statements
"no-duplicate-case": "error",
- // Disallow unnecessary calls to .bind()
- "no-extra-bind": "error",
-
- // Disallow eval and setInteral/setTimeout with strings
- "no-implied-eval": "error",
- "no-eval": "error",
-
- // No labels
- "no-labels": "error",
-
- // Disallow unnecessary nested blocks
- "no-lone-blocks": "error",
-
// If an if block ends with a return no need for an else block
"no-else-return": "error",
// No empty statements
"no-empty": ["error", {"allowEmptyCatch": true}],
// No empty character classes in regex
"no-empty-character-class": "error",
// Disallow empty destructuring
"no-empty-pattern": "error",
+ // Disallow eval and setInteral/setTimeout with strings
+ "no-eval": "error",
+
// No assigning to exception variable
"no-ex-assign": "error",
+ // Disallow unnecessary calls to .bind()
+ "no-extra-bind": "error",
+
// No using !! where casting to boolean is already happening
"no-extra-boolean-cast": "error",
// No double semicolon
"no-extra-semi": "error",
// No overwriting defined functions
"no-func-assign": "error",
+ // Disallow eval and setInteral/setTimeout with strings
+ "no-implied-eval": "error",
+
// No invalid regular expresions
"no-invalid-regexp": "error",
// No odd whitespace characters
"no-irregular-whitespace": "error",
// Disallow the use of the __iterator__ property
"no-iterator": "error",
+ // No labels
+ "no-labels": "error",
+
+ // Disallow unnecessary nested blocks
+ "no-lone-blocks": "error",
+
// No single if block inside an else block
"no-lonely-if": "error",
// No mixing spaces and tabs in indent
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
// No unnecessary spacing
"no-multi-spaces": ["error", { exceptions: {
+ "ArrayExpression": true,
"AssignmentExpression": true,
- "VariableDeclarator": true,
- "ArrayExpression": true,
- "ObjectExpression": true
+ "ObjectExpression": true,
+ "VariableDeclarator": true
} }],
// No reassigning native JS objects
"no-native-reassign": "error",
// Nested ternary statements are confusing
"no-nested-ternary": "error",
@@ -225,41 +265,45 @@ module.exports = {
// Disallow control flow statements in finally blocks
"no-unsafe-finally": "error",
// No (!foo in bar) or (!object instanceof Class)
"no-unsafe-negation": "error",
// No declaring variables that are never used
"no-unused-vars": ["error", {
+ "args": "none",
"vars": "local",
- "varsIgnorePattern": "^Cc|Ci|Cu|Cr|EXPORTED_SYMBOLS",
- "args": "none"
+ "varsIgnorePattern": "^Cc|Ci|Cu|Cr|EXPORTED_SYMBOLS"
}],
// No using variables before defined
// "no-use-before-define": ["error", "nofunc"],
// Disallow unnecessary .call() and .apply()
"no-useless-call": "error",
+ // Don't concatenate string literals together (unless they span multiple
+ // lines)
+ "no-useless-concat": "error",
+
// Disallow redundant return statements
"no-useless-return": "error",
// No using with
"no-with": "error",
// Require object-literal shorthand with ES6 method syntax
"object-shorthand": ["error", "always", { "avoidQuotes": true }],
// Require double-quotes everywhere, except where quotes are escaped
// or template literals are used.
"quotes": ["error", "double", {
- "avoidEscape": true,
- "allowTemplateLiterals": true
+ "allowTemplateLiterals": true,
+ "avoidEscape": true
}],
// No spacing inside rest or spread expressions
"rest-spread-spacing": "error",
// Always require semicolon at end of statement
// "semi": ["error", "always"],
@@ -272,63 +316,25 @@ module.exports = {
// No space padding in parentheses
// "space-in-parens": ["error", "never"],
// Require spaces around operators
"space-infix-ops": ["error", { "int32Hint": true }],
// ++ and -- should not need spacing
"space-unary-ops": ["error", {
- "words": true,
"nonwords": false,
"overrides": {
"typeof": false // We tend to use typeof as a function call
- }
+ },
+ "words": true
}],
// Requires or disallows a whitespace (space or tab) beginning a comment
"spaced-comment": "error",
// No comparisons to NaN
"use-isnan": "error",
// Only check typeof against valid results
- "valid-typeof": "error",
-
- // Don't concatenate string literals together (unless they span multiple
- // lines)
- "no-useless-concat": "error"
- },
- "globals": {
- "BroadcastChannel": false,
- // Specific to Firefox (Chrome code only).
- "ChromeWindow": false,
- "ChromeWorker": false,
- "ChromeUtils": false,
- "Components": false,
- "CSSPrimitiveValue": false,
- "CSSValueList": false,
- "dump": true,
- "ImageDocument": false,
- // Non-standard, specific to Firefox.
- "InstallTrigger": false,
- // Specific to Firefox
- // eslint-disable-next-line max-len
- // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
- "InternalError": true,
- "KeyEvent": false,
- "openDialog": false,
- "MenuBoxObject": false,
- // Specific to Firefox (Chrome code only).
- "MozSelfSupport": false,
- "SimpleGestureEvent": false,
- "sizeToContent": false,
- "SharedArrayBuffer": false,
- // Note: StopIteration will likely be removed as part of removing legacy
- // generators, see bug 968038.
- "StopIteration": false,
- // Specific to Firefox
- // eslint-disable-next-line max-len
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
- "uneval": false,
- "XULElement": false
+ "valid-typeof": "error"
}
};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
@@ -1,24 +1,19 @@
// Parent config file for all xpcshell files.
"use strict";
module.exports = {
- rules: {
- "mozilla/import-headjs-globals": "warn",
- "mozilla/mark-test-function-used": "warn",
- "no-shadow": "error"
- },
-
// All globals made available in the test environment.
"globals": {
+ "Assert": false,
+ "PromiseDebugging": false,
"_TEST_FILE": false,
"add_task": false,
"add_test": false,
- "Assert": false,
"deepEqual": false,
"do_await_remote_message": false,
"do_check_eq": false,
"do_check_false": false,
"do_check_instanceof": false,
"do_check_matches": false,
"do_check_neq": false,
"do_check_null": false,
@@ -49,26 +44,31 @@ module.exports = {
"less": false,
"lessOrEqual": false,
"load": false,
"mozinfo": false,
"notDeepEqual": false,
"notEqual": false,
"notStrictEqual": false,
"ok": false,
- "PromiseDebugging": false,
- "runningInParent": false,
"run_next_test": false,
"run_test": false,
"run_test_in_child": false,
+ "runningInParent": false,
// Defined in XPCShellImpl.
"sendCommand": false,
"strictEqual": false,
"throws": false,
"todo": false,
"todo_check_false": false,
"todo_check_true": false,
// Firefox specific function.
// eslint-disable-next-line max-len
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
"uneval": false
+ },
+
+ rules: {
+ "mozilla/import-headjs-globals": "warn",
+ "mozilla/mark-test-function-used": "warn",
+ "no-shadow": "error"
}
};