1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
6 plugins: ["react", "mozilla", "import"],
30 extends: ["prettier", "plugin:jest/recommended"],
32 ecmaVersion: "latest",
34 ecmaFeatures: { jsx: true },
43 // These are the rules that have been configured so far to match the
44 // devtools coding style.
46 // Rules from the mozilla plugin
47 "mozilla/mark-test-function-used": "error",
48 "mozilla/no-aArgs": "error",
50 "mozilla/reject-importGlobalProperties": "error",
51 "mozilla/var-only-at-top-level": "error",
53 // Rules from the React plugin
54 "react/jsx-uses-react": "error",
55 "react/jsx-uses-vars": "error",
56 "react/no-danger": "error",
57 "react/no-did-mount-set-state": "error",
58 "react/no-did-update-set-state": "error",
59 "react/no-direct-mutation-state": "error",
60 "react/no-unknown-property": "error",
61 "react/prop-types": "off",
65 order: ["propTypes", "everything-else", "render"],
69 // Check for import errors.
70 "import/no-duplicates": "error",
71 "import/named": "error",
72 "import/export": "error",
74 // Incompatible with jest-in-case cases. See related GitHub issue
75 // https://github.com/jest-community/eslint-plugin-jest/issues/534
76 "jest/no-standalone-expect": "off",
78 // Disallow flow control that escapes from "finally".
79 "no-unsafe-finally": "error",
81 // Disallow using variables outside the blocks they are defined (especially
82 // since only let and const are used, see "no-var").
83 "block-scoped-var": 2,
84 // Require camel case names
85 camelcase: ["error", { properties: "never" }],
86 // Warn about cyclomatic complexity in functions.
87 complexity: ["error", { max: 22 }],
88 // Don't warn for inconsistent naming when capturing this (not so important
89 // with auto-binding fat arrow functions).
91 // Don't require a default case in switch statements. Avoid being forced to
92 // add a bogus default when you know all possible cases are handled.
94 // Encourage the use of dot notation whenever possible.
96 // Allow using == instead of ===, in the interest of landing something since
97 // the devtools codebase is split on convention here.
99 // Don't require function expressions to have a name.
100 // This makes the code more verbose and hard to read. Our engine already
101 // does a fantastic job assigning a name to the function, which includes
102 // the enclosing function name, and worst case you have a line number that
103 // you can just look up.
105 // Allow use of function declarations and expressions.
107 // Deprecated, will be removed in 1.0.
109 // Only useful in a node environment.
110 "handle-callback-err": 0,
111 // Maximum depth callbacks can be nested.
112 "max-nested-callbacks": [2, 4],
113 // Don't limit the number of parameters that can be used in a function.
115 // Don't limit the maximum number of statement allowed in a function. We
116 // already have the complexity rule that's a better measurement.
118 // Require a capital letter for constructors, only check if all new
119 // operators are followed by a capital letter. Don't warn when capitalized
120 // functions are used without the new operator.
121 "new-cap": [2, { capIsNew: false }],
122 // Disallow use of the Array constructor.
123 "no-array-constructor": 2,
124 // Allow use of bitwise operators.
126 // Disallow use of arguments.caller or arguments.callee.
128 // Disallow the catch clause parameter name being the same as a variable in
129 // the outer scope, to avoid confusion.
130 "no-catch-shadow": 2,
131 // Disallow assignment in conditional expressions.
133 // Allow use of the continue statement.
135 // Disallow control characters in regular expressions.
136 "no-control-regex": 2,
137 // Disallow use of debugger.
139 // Disallow deletion of variables (deleting properties is fine).
141 // Allow division operators explicitly at beginning of regular expression.
143 // Disallow duplicate arguments in functions.
145 // Disallow a duplicate case label.
146 "no-duplicate-case": 2,
147 // Disallow else after a return in an if. The else around the second return
149 // if (something) { return false; } else { return true; }
151 // Disallow empty statements. This will report an error for:
152 // try { something(); } catch (e) {}
153 // but will not report it for:
154 // try { something(); } catch (e) { /* Silencing the error because ...*/ }
155 // which is a valid use case.
157 // Disallow the use of empty character classes in regular expressions.
158 "no-empty-character-class": 2,
159 // Disallow use of labels for anything other then loops and switches.
161 // Disallow use of eval(). We have other APIs to evaluate code in content.
163 // Disallow assigning to the exception in a catch block.
165 // Disallow adding to native types
166 "no-extend-native": 2,
167 // Disallow unnecessary function binding.
169 // Disallow double-negation boolean casts in a boolean context.
170 "no-extra-boolean-cast": 2,
171 // Deprecated, will be removed in 1.0.
172 "no-extra-strict": 0,
173 // Disallow comments inline after code.
174 "no-inline-comments": 2,
175 // Disallow if as the only statement in an else block.
177 // Allow mixing regular variable and require declarations (not a node env).
178 "no-mixed-requires": 0,
179 // Disallow use of multiline strings (use template strings instead).
181 "prefer-template": "error",
185 destructuring: "all",
186 ignoreReadBeforeAssign: false,
189 // Disallow reassignments of native objects.
190 "no-native-reassign": 2,
191 // Disallow nested ternary expressions, they make the code hard to read.
192 "no-nested-ternary": 2,
193 // Allow use of new operator with the require function.
195 // Disallow use of octal literals.
197 // Allow reassignment of function parameters.
198 "no-param-reassign": 0,
199 // Allow string concatenation with __dirname and __filename (not a node env).
201 // Allow use of unary operators, ++ and --.
203 // Allow using process.env (not a node environment).
205 // Allow using process.exit (not a node environment).
206 "no-process-exit": 0,
207 // Disallow usage of __proto__ property.
209 // Disallow multiple spaces in a regular expression literal.
210 "no-regex-spaces": 2,
211 // Don't restrict usage of specified node modules (not a node environment).
212 "no-restricted-modules": 0,
213 // Disallow use of assignment in return statement. It is preferable for a
214 // single line of code to have only one easily predictable effect.
215 "no-return-assign": 2,
216 // Allow use of javascript: urls.
218 // Disallow comparisons where both sides are exactly the same.
219 "no-self-compare": 2,
220 // Disallow use of comma operator.
222 // Disallow sparse arrays, eg. let arr = [,,2].
223 // Array destructuring is fine though:
224 // for (let [, breakpointPromise] of aPromises)
225 "no-sparse-arrays": 2,
226 // Allow use of synchronous methods (not a node environment).
228 // Allow the use of ternary operators.
230 // Disallow throwing literals (eg. throw "error" instead of
231 // throw new Error("error")).
232 "no-throw-literal": 2,
233 // Disallow use of undeclared variables unless mentioned in a /*global */
234 // block. Note that globals from head.js are automatically imported in tests
235 // by the import-headjs-globals rule form the mozilla eslint plugin.
237 // Allow dangling underscores in identifiers (for privates).
238 "no-underscore-dangle": 0,
239 // Allow use of undefined variable.
241 // Disallow the use of Boolean literals in conditional expressions.
242 "no-unneeded-ternary": 2,
243 // Disallow unreachable statements after a return, throw, continue, or break
246 // Disallow global and local variables that arent used. Allow unused function arguments
247 // that are prefixed with `_`.
248 "no-unused-vars": [2, { vars: "all", argsIgnorePattern: "^_" }],
249 // Allow using variables before they are defined.
250 "no-use-before-define": 0,
251 // We use var-only-at-top-level instead of no-var as we allow top level
254 // Allow using TODO/FIXME comments.
255 "no-warning-comments": 0,
256 // Allow more than one variable declaration per function.
258 // Require use of the second argument for parseInt().
260 // Dont require to sort variables within the same declaration block.
261 // Anyway, one-var is disabled.
263 // Require "use strict" to be defined globally in the script.
264 strict: [2, "global"],
265 // Disallow comparisons with the value NaN.
267 // Ensure that the results of typeof are compared against a valid string.
269 // Allow vars to be declared anywhere in the scope.
271 // Disallow Yoda conditions (where literal value comes first).
274 // And these are the rules that haven't been discussed so far, and that are
275 // disabled for now until we introduce them, one at a time.
277 // Require for-in loops to have an if statement.
279 // allow/disallow an empty newline after var statement
280 "newline-after-var": 0,
281 // disallow the use of alert, confirm, and prompt
283 // disallow comparisons to null without a type-checking operator
285 // disallow overwriting functions written as function declarations
287 // disallow use of eval()-like methods
288 "no-implied-eval": 0,
289 // disallow function or variable declarations in nested blocks
290 "no-inner-declarations": 0,
291 // disallow invalid regular expression strings in the RegExp constructor
292 "no-invalid-regexp": 0,
293 // disallow irregular whitespace outside of strings and comments
294 "no-irregular-whitespace": 0,
295 // disallow labels that share a name with a variable
297 // disallow unnecessary nested blocks
299 // disallow creation of functions within loops
301 // disallow negation of the left operand of an in expression
302 "no-negated-in-lhs": 0,
303 // disallow use of new operator when not part of the assignment or
306 // disallow use of new operator for Function object
308 // disallow use of the Object constructor
310 // disallows creating new instances of String,Number, and Boolean
311 "no-new-wrappers": 0,
312 // disallow the use of object properties of the global object (Math and
313 // JSON) as functions
315 // disallow use of octal escape sequences in string literals, such as
316 // var foo = "Copyright \251";
317 "no-octal-escape": 0,
318 // disallow use of undefined when initializing variables
320 // disallow usage of expressions in statement position
321 "no-unused-expressions": 0,
322 // disallow use of void operator
324 // require assignment operator shorthand where possible or prohibit it
326 "operator-assignment": 0,
330 // Keep in sync with "jest" version from debugger's package.json