Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug...
[gecko.git] / devtools / client / debugger / src / .eslintrc.js
blob0607f8f7d55880a0cd20281a85fcb3191fc16ff2
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/>. */
5 module.exports = {
6   plugins: ["react", "mozilla", "@babel", "import", "file-header"],
7   globals: {
8     atob: true,
9     btoa: true,
10     Cc: true,
11     Ci: true,
12     Components: true,
13     console: true,
14     Cr: true,
15     Cu: true,
16     devtools: true,
17     dump: true,
18     EventEmitter: true,
19     isWorker: true,
20     loader: true,
21     Services: true,
22     Task: true,
23     XPCOMUtils: true,
24     _Iterator: true,
25     __dirname: true,
26     process: true,
27     global: true,
28     L10N: true,
29   },
30   extends: ["prettier", "plugin:jest/recommended"],
31   parserOptions: {
32     ecmaVersion: "latest",
33     sourceType: "module",
34     ecmaFeatures: { jsx: true },
36     // When the linter runs from the MC root, it won't pick up this project's
37     // babel.config.js, so we explicitly set Babel's root location so that
38     // it knows where to look.
39     babelOptions: {
40       root: __dirname,
41     },
42   },
43   env: {
44     es6: true,
45     browser: true,
46     commonjs: true,
47     jest: true,
48   },
49   rules: {
50     // These are the rules that have been configured so far to match the
51     // devtools coding style.
53     // Rules from the mozilla plugin
54     "mozilla/mark-test-function-used": "error",
55     "mozilla/no-aArgs": "error",
56     // See bug 1224289.
57     "mozilla/reject-importGlobalProperties": "error",
58     "mozilla/var-only-at-top-level": "error",
60     // Rules from the React plugin
61     "react/jsx-uses-react": "error",
62     "react/jsx-uses-vars": "error",
63     "react/no-danger": "error",
64     "react/no-did-mount-set-state": "error",
65     "react/no-did-update-set-state": "error",
66     "react/no-direct-mutation-state": "error",
67     "react/no-unknown-property": "error",
68     "react/prop-types": "off",
69     "react/sort-comp": [
70       "error",
71       {
72         order: ["propTypes", "everything-else", "render"],
73       },
74     ],
76     // Check for import errors.
77     "import/no-duplicates": "error",
78     "import/named": "error",
79     "import/export": "error",
81     // Incompatible with jest-in-case cases. See related GitHub issue
82     // https://github.com/jest-community/eslint-plugin-jest/issues/534
83     "jest/no-standalone-expect": "off",
85     // Disallow flow control that escapes from "finally".
86     "no-unsafe-finally": "error",
88     // Disallow using variables outside the blocks they are defined (especially
89     // since only let and const are used, see "no-var").
90     "block-scoped-var": 2,
91     // Require camel case names
92     camelcase: ["error", { properties: "never" }],
93     // Warn about cyclomatic complexity in functions.
94     complexity: ["error", { max: 22 }],
95     // Don't warn for inconsistent naming when capturing this (not so important
96     // with auto-binding fat arrow functions).
97     "consistent-this": 0,
98     // Don't require a default case in switch statements. Avoid being forced to
99     // add a bogus default when you know all possible cases are handled.
100     "default-case": 0,
101     // Encourage the use of dot notation whenever possible.
102     "dot-notation": 2,
103     // Allow using == instead of ===, in the interest of landing something since
104     // the devtools codebase is split on convention here.
105     eqeqeq: 0,
106     // Don't require function expressions to have a name.
107     // This makes the code more verbose and hard to read. Our engine already
108     // does a fantastic job assigning a name to the function, which includes
109     // the enclosing function name, and worst case you have a line number that
110     // you can just look up.
111     "func-names": 0,
112     // Allow use of function declarations and expressions.
113     "func-style": 0,
114     // Deprecated, will be removed in 1.0.
115     "global-strict": 0,
116     // Only useful in a node environment.
117     "handle-callback-err": 0,
118     // Don't enforce the maximum depth that blocks can be nested. The complexity
119     // rule is a better rule to check this.
120     "max-depth": 0,
121     // Maximum depth callbacks can be nested.
122     "max-nested-callbacks": [2, 4],
123     // Don't limit the number of parameters that can be used in a function.
124     "max-params": 0,
125     // Don't limit the maximum number of statement allowed in a function. We
126     // already have the complexity rule that's a better measurement.
127     "max-statements": 0,
128     // Require a capital letter for constructors, only check if all new
129     // operators are followed by a capital letter. Don't warn when capitalized
130     // functions are used without the new operator.
131     "new-cap": [2, { capIsNew: false }],
132     // Disallow use of the Array constructor.
133     "no-array-constructor": 2,
134     // Allow use of bitwise operators.
135     "no-bitwise": 0,
136     // Disallow use of arguments.caller or arguments.callee.
137     "no-caller": 2,
138     // Disallow the catch clause parameter name being the same as a variable in
139     // the outer scope, to avoid confusion.
140     "no-catch-shadow": 2,
141     // Disallow assignment in conditional expressions.
142     "no-cond-assign": 2,
143     // Allow using the console API.
144     "no-console": 0,
145     // Allow using constant expressions in conditions like while (true)
146     "no-constant-condition": 0,
147     // Allow use of the continue statement.
148     "no-continue": 0,
149     // Disallow control characters in regular expressions.
150     "no-control-regex": 2,
151     // Disallow use of debugger.
152     "no-debugger": 2,
153     // Disallow deletion of variables (deleting properties is fine).
154     "no-delete-var": 2,
155     // Allow division operators explicitly at beginning of regular expression.
156     "no-div-regex": 0,
157     // Disallow duplicate arguments in functions.
158     "no-dupe-args": 2,
159     // Disallow duplicate keys when creating object literals.
160     "no-dupe-keys": 2,
161     // Disallow a duplicate case label.
162     "no-duplicate-case": 2,
163     // Disallow else after a return in an if. The else around the second return
164     // here is useless:
165     // if (something) { return false; } else { return true; }
166     "no-else-return": 2,
167     // Disallow empty statements. This will report an error for:
168     // try { something(); } catch (e) {}
169     // but will not report it for:
170     // try { something(); } catch (e) { /* Silencing the error because ...*/ }
171     // which is a valid use case.
172     "no-empty": 2,
173     // Disallow the use of empty character classes in regular expressions.
174     "no-empty-character-class": 2,
175     // Disallow use of labels for anything other then loops and switches.
176     "no-labels": 2,
177     // Disallow use of eval(). We have other APIs to evaluate code in content.
178     "no-eval": 2,
179     // Disallow assigning to the exception in a catch block.
180     "no-ex-assign": 2,
181     // Disallow adding to native types
182     "no-extend-native": 2,
183     // Disallow unnecessary function binding.
184     "no-extra-bind": 2,
185     // Disallow double-negation boolean casts in a boolean context.
186     "no-extra-boolean-cast": 2,
187     // Deprecated, will be removed in 1.0.
188     "no-extra-strict": 0,
189     // Disallow fallthrough of case statements, except if there is a comment.
190     "no-fallthrough": 2,
191     // Disallow comments inline after code.
192     "no-inline-comments": 2,
193     // Disallow if as the only statement in an else block.
194     "no-lonely-if": 2,
195     // Allow mixing regular variable and require declarations (not a node env).
196     "no-mixed-requires": 0,
197     // Disallow use of multiline strings (use template strings instead).
198     "no-multi-str": 2,
199     "prefer-template": "error",
200     "prefer-const": [
201       "error",
202       {
203         destructuring: "all",
204         ignoreReadBeforeAssign: false,
205       },
206     ],
207     // Disallow reassignments of native objects.
208     "no-native-reassign": 2,
209     // Disallow nested ternary expressions, they make the code hard to read.
210     "no-nested-ternary": 2,
211     // Allow use of new operator with the require function.
212     "no-new-require": 0,
213     // Disallow use of octal literals.
214     "no-octal": 2,
215     // Allow reassignment of function parameters.
216     "no-param-reassign": 0,
217     // Allow string concatenation with __dirname and __filename (not a node env).
218     "no-path-concat": 0,
219     // Allow use of unary operators, ++ and --.
220     "no-plusplus": 0,
221     // Allow using process.env (not a node environment).
222     "no-process-env": 0,
223     // Allow using process.exit (not a node environment).
224     "no-process-exit": 0,
225     // Disallow usage of __proto__ property.
226     "no-proto": 2,
227     // Disallow declaring the same variable more than once (we use let anyway).
228     "no-redeclare": 2,
229     // Disallow multiple spaces in a regular expression literal.
230     "no-regex-spaces": 2,
231     // Don't restrict usage of specified node modules (not a node environment).
232     "no-restricted-modules": 0,
233     // Disallow use of assignment in return statement. It is preferable for a
234     // single line of code to have only one easily predictable effect.
235     "no-return-assign": 2,
236     // Allow use of javascript: urls.
237     "no-script-url": 0,
238     // Disallow comparisons where both sides are exactly the same.
239     "no-self-compare": 2,
240     // Disallow use of comma operator.
241     "no-sequences": 2,
242     // Warn about declaration of variables already declared in the outer scope.
243     // This isn't an error because it sometimes is useful to use the same name
244     // in a small helper function rather than having to come up with another
245     // random name.
246     // Still, making this a warning can help people avoid being confused.
247     "no-shadow": 2,
248     // Disallow shadowing of names such as arguments.
249     "no-shadow-restricted-names": 2,
250     // Disallow sparse arrays, eg. let arr = [,,2].
251     // Array destructuring is fine though:
252     // for (let [, breakpointPromise] of aPromises)
253     "no-sparse-arrays": 2,
254     // Allow use of synchronous methods (not a node environment).
255     "no-sync": 0,
256     // Allow the use of ternary operators.
257     "no-ternary": 0,
258     // Disallow throwing literals (eg. throw "error" instead of
259     // throw new Error("error")).
260     "no-throw-literal": 2,
261     // Disallow use of undeclared variables unless mentioned in a /*global */
262     // block. Note that globals from head.js are automatically imported in tests
263     // by the import-headjs-globals rule form the mozilla eslint plugin.
264     "no-undef": 2,
265     // Allow dangling underscores in identifiers (for privates).
266     "no-underscore-dangle": 0,
267     // Allow use of undefined variable.
268     "no-undefined": 0,
269     // Disallow the use of Boolean literals in conditional expressions.
270     "no-unneeded-ternary": 2,
271     // Disallow unreachable statements after a return, throw, continue, or break
272     // statement.
273     "no-unreachable": 2,
274     // Disallow global and local variables that arent used, but allow unused function arguments.
275     "no-unused-vars": [2, { vars: "all", args: "none" }],
276     // Allow using variables before they are defined.
277     "no-use-before-define": 0,
278     // We use var-only-at-top-level instead of no-var as we allow top level
279     // vars.
280     "no-var": 0,
281     // Allow using TODO/FIXME comments.
282     "no-warning-comments": 0,
283     // Disallow use of the with statement.
284     "no-with": 2,
285     // Dont require method and property shorthand syntax for object literals.
286     // We use this in the code a lot, but not consistently, and this seems more
287     // like something to check at code review time.
288     "object-shorthand": 0,
289     // Allow more than one variable declaration per function.
290     "one-var": 0,
291     // Require use of the second argument for parseInt().
292     radix: 2,
293     // Dont require to sort variables within the same declaration block.
294     // Anyway, one-var is disabled.
295     "sort-vars": 0,
296     // Require "use strict" to be defined globally in the script.
297     strict: [2, "global"],
298     // Disallow comparisons with the value NaN.
299     "use-isnan": 2,
300     // Ensure that the results of typeof are compared against a valid string.
301     "valid-typeof": 2,
302     // Allow vars to be declared anywhere in the scope.
303     "vars-on-top": 0,
304     // Disallow Yoda conditions (where literal value comes first).
305     yoda: 2,
307     // And these are the rules that haven't been discussed so far, and that are
308     // disabled for now until we introduce them, one at a time.
310     // Require for-in loops to have an if statement.
311     "guard-for-in": 0,
312     // allow/disallow an empty newline after var statement
313     "newline-after-var": 0,
314     // disallow the use of alert, confirm, and prompt
315     "no-alert": 0,
316     // disallow comparisons to null without a type-checking operator
317     "no-eq-null": 0,
318     // disallow overwriting functions written as function declarations
319     "no-func-assign": 0,
320     // disallow use of eval()-like methods
321     "no-implied-eval": 0,
322     // disallow function or variable declarations in nested blocks
323     "no-inner-declarations": 0,
324     // disallow invalid regular expression strings in the RegExp constructor
325     "no-invalid-regexp": 0,
326     // disallow irregular whitespace outside of strings and comments
327     "no-irregular-whitespace": 0,
328     // disallow labels that share a name with a variable
329     "no-label-var": 0,
330     // disallow unnecessary nested blocks
331     "no-lone-blocks": 0,
332     // disallow creation of functions within loops
333     "no-loop-func": 0,
334     // disallow negation of the left operand of an in expression
335     "no-negated-in-lhs": 0,
336     // disallow use of new operator when not part of the assignment or
337     // comparison
338     "no-new": 0,
339     // disallow use of new operator for Function object
340     "no-new-func": 0,
341     // disallow use of the Object constructor
342     "no-new-object": 0,
343     // disallows creating new instances of String,Number, and Boolean
344     "no-new-wrappers": 0,
345     // disallow the use of object properties of the global object (Math and
346     // JSON) as functions
347     "no-obj-calls": 0,
348     // disallow use of octal escape sequences in string literals, such as
349     // var foo = "Copyright \251";
350     "no-octal-escape": 0,
351     // disallow use of undefined when initializing variables
352     "no-undef-init": 0,
353     // disallow usage of expressions in statement position
354     "no-unused-expressions": 0,
355     // disallow use of void operator
356     "no-void": 0,
357     // require assignment operator shorthand where possible or prohibit it
358     // entirely
359     "operator-assignment": 0,
361     "file-header/file-header": [
362       "error",
363       [
364         "This Source Code Form is subject to the terms of the Mozilla Public",
365         "License, v. 2.0. If a copy of the MPL was not distributed with this",
366         "file, You can obtain one at <http://mozilla.org/MPL/2.0/>.",
367       ],
368       "block",
369       ["-\\*-(.*)-\\*-", "eslint(.*)", "vim(.*)"],
370     ],
371   },