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/. */
19 files: ["client/framework/**"],
21 "no-return-assign": "off",
26 "client/shared/*.jsm",
27 // Allow non-camelcase so that run_test doesn't produce a warning.
36 "client/framework/**",
37 "client/shared/*.jsm",
38 "client/shared/widgets/*.jsm",
39 "client/storage/VariablesView.jsm",
42 "consistent-return": "off",
46 files: ["client/framework/**"],
48 "max-nested-callbacks": "off",
53 "client/framework/**",
54 "client/shared/*.jsm",
55 "client/shared/widgets/*.jsm",
56 "client/storage/VariablesView.jsm",
57 "shared/webconsole/test/chrome/*.html",
60 "mozilla/no-aArgs": "off",
64 files: ["client/framework/test/**"],
66 "mozilla/var-only-at-top-level": "off",
71 "client/framework/**",
72 "client/shared/widgets/*.jsm",
73 "client/storage/VariablesView.jsm",
80 files: ["client/framework/**"],
86 // For all head*.js files, turn off no-unused-vars at a global level
87 files: ["**/head*.js"],
89 "no-unused-vars": ["error", { args: "none", vars: "local" }],
93 // For all server and shared files, prevent requiring devtools/client
95 files: ["server/**", "shared/**"],
97 "mozilla/reject-some-requires": [
99 "^(resource://)?devtools/client",
103 // Tests can always import anything.
108 // Cu, Cc etc... are not available in most devtools modules loaded by require.
111 // Enable the rule on JSM, test head files and some specific files.
113 "**/test/**/head.js",
114 "**/test/**/shared-head.js",
115 "client/debugger/test/mochitest/code_frame-script.js",
116 "client/responsive.html/browser/content.js",
117 "client/shared/browser-loader.js",
118 "server/actors/webconsole/content-process-forward.js",
119 "server/actors/worker/service-worker-process.js",
120 "server/startup/content-process.js",
121 "server/startup/frame.js",
122 "shared/base-loader.js",
123 "shared/worker/loader.js",
124 "startup/aboutdebugging-registration.js",
125 "startup/aboutdevtools/aboutdevtools-registration.js",
126 "startup/aboutdevtoolstoolbox-registration.js",
127 "startup/devtools-startup.js",
130 "mozilla/no-define-cc-etc": "off",
134 // All DevTools files should avoid relative paths.
137 // Debugger modules have a custom bundling logic which relies on relative
139 "client/debugger/**",
140 // `client/shared/build` contains node helpers to build the debugger and
141 // not devtools modules.
142 "client/shared/build/**",
145 "mozilla/reject-relative-requires": "error",
150 // These are the rules that have been configured so far to match the
151 // devtools coding style.
153 // Rules from the mozilla plugin
154 "mozilla/balanced-observers": "error",
155 "mozilla/no-aArgs": "error",
157 "mozilla/reject-importGlobalProperties": ["error", "everything"],
158 "mozilla/var-only-at-top-level": "error",
159 "mozilla/use-chromeutils-import": ["error", { allowCu: true }],
161 // Rules from the React plugin
162 "react/display-name": "error",
163 "react/no-danger": "error",
164 "react/no-did-mount-set-state": "error",
165 "react/no-did-update-set-state": "error",
166 "react/no-direct-mutation-state": "error",
167 "react/no-unknown-property": "error",
168 "react/prefer-es6-class": ["off", "always"],
169 "react/prop-types": "error",
173 order: ["static-methods", "lifecycle", "everything-else", "render"],
188 "componentWillMount",
190 "componentWillReceiveProps",
191 "shouldComponentUpdate",
192 "componentWillUpdate",
193 "componentDidUpdate",
194 "componentWillUnmount",
200 // Disallow using variables outside the blocks they are defined (especially
201 // since only let and const are used, see "no-var").
202 "block-scoped-var": "error",
203 // Require camel case names
204 camelcase: ["error", { properties: "never" }],
205 // Warn about cyclomatic complexity in functions.
206 // 20 is ESLint's default, and we want to keep it this way to prevent new highly
207 // complex functions from being introduced. However, because Mozilla's eslintrc has
208 // some other value defined, we need to override it here. See bug 1553449 for more
209 // information on complex DevTools functions that are currently excluded.
210 complexity: ["error", 20],
211 // Don't warn for inconsistent naming when capturing this (not so important
212 // with auto-binding fat arrow functions).
213 "consistent-this": "off",
214 // Don't require a default case in switch statements. Avoid being forced to
215 // add a bogus default when you know all possible cases are handled.
216 "default-case": "off",
217 // Allow using == instead of ===, in the interest of landing something since
218 // the devtools codebase is split on convention here.
220 // Don't require function expressions to have a name.
221 // This makes the code more verbose and hard to read. Our engine already
222 // does a fantastic job assigning a name to the function, which includes
223 // the enclosing function name, and worst case you have a line number that
224 // you can just look up.
226 // Allow use of function declarations and expressions.
228 // Only useful in a node environment.
229 "handle-callback-err": "off",
230 // componentDidUnmount is not a real lifecycle method, use componentWillUnmount.
231 "id-denylist": ["error", "componentDidUnmount"],
232 // Maximum depth callbacks can be nested.
233 "max-nested-callbacks": ["error", 3],
234 // Don't limit the number of parameters that can be used in a function.
236 // Don't limit the maximum number of statement allowed in a function. We
237 // already have the complexity rule that's a better measurement.
238 "max-statements": "off",
239 // Require a capital letter for constructors, only check if all new
240 // operators are followed by a capital letter. Don't warn when capitalized
241 // functions are used without the new operator.
242 "new-cap": ["error", { capIsNew: false }],
243 // Allow use of bitwise operators.
245 // Allow using the console API.
247 // Allow using constant expressions in conditions like while (true)
248 "no-constant-condition": "off",
249 // Allow use of the continue statement.
250 "no-continue": "off",
251 // Allow division operators explicitly at beginning of regular expression.
252 "no-div-regex": "off",
253 // Disallow empty statements. This will report an error for:
254 // try { something(); } catch (e) {}
255 // but will not report it for:
256 // try { something(); } catch (e) { /* Silencing the error because ...*/ }
257 // which is a valid use case.
259 // Disallow adding to native types
260 "no-extend-native": "error",
261 // Disallow fallthrough of case statements, except if there is a comment.
262 "no-fallthrough": "error",
263 // Allow comments inline after code.
264 "no-inline-comments": "off",
265 // Allow mixing regular variable and require declarations (not a node env).
266 "no-mixed-requires": "off",
267 // Disallow use of multiline strings (use template strings instead).
268 "no-multi-str": "error",
269 // Allow use of new operator with the require function.
270 "no-new-require": "off",
271 // Allow reassignment of function parameters.
272 "no-param-reassign": "off",
273 // Allow string concatenation with __dirname and __filename (not a node env).
274 "no-path-concat": "off",
275 // Allow use of unary operators, ++ and --.
276 "no-plusplus": "off",
277 // Allow using process.env (not a node environment).
278 "no-process-env": "off",
279 // Allow using process.exit (not a node environment).
280 "no-process-exit": "off",
281 // Disallow usage of __proto__ property.
283 // Disallow multiple spaces in a regular expression literal.
284 "no-regex-spaces": "off",
285 // Don't restrict usage of specified node modules (not a node environment).
286 "no-restricted-modules": "off",
287 // Prevent using some properties
288 "no-restricted-properties": [
291 property: "setupInParent",
292 message: "avoid child/parent communication with setupInParent",
295 // Disallow use of assignment in return statement. It is preferable for a
296 // single line of code to have only one easily predictable effect.
297 "no-return-assign": "error",
298 // Allow use of javascript: urls.
299 "no-script-url": "off",
300 // Warn about declaration of variables already declared in the outer scope.
301 // This isn't an error because it sometimes is useful to use the same name
302 // in a small helper function rather than having to come up with another
304 // Still, making this a warning can help people avoid being confused.
305 "no-shadow": "error",
306 // Allow use of synchronous methods (not a node environment).
308 // Allow the use of ternary operators.
310 // Allow dangling underscores in identifiers (for privates).
311 "no-underscore-dangle": "off",
312 // Allow use of undefined variable.
313 "no-undefined": "off",
314 // Disallow global and local variables that aren't used, but allow unused
315 // function arguments.
316 "no-unused-vars": ["error", { args: "none", vars: "all" }],
317 // Allow using variables before they are defined.
318 "no-use-before-define": "off",
319 // We use var-only-at-top-level instead of no-var as we allow top level
322 // Allow using TODO/FIXME comments.
323 "no-warning-comments": "off",
324 // Don't require method and property shorthand syntax for object literals.
325 // We use this in the code a lot, but not consistently, and this seems more
326 // like something to check at code review time.
327 "object-shorthand": "off",
328 // Allow more than one variable declaration per function.
330 // Enforce using `let` only when variables are reassigned.
331 "prefer-const": ["error", { destructuring: "all" }],
332 // Require use of the second argument for parseInt().
334 // Don't require to sort variables within the same declaration block.
335 // Anyway, one-var is disabled.
337 // Require "use strict" to be defined globally in the script.
338 strict: ["error", "global"],
339 // Warn about invalid JSDoc comments.
340 // Disabled for now because of https://github.com/eslint/eslint/issues/2270
341 // The rule fails on some jsdoc comments like in:
342 // devtools/client/webconsole/old/console-output.js
343 "valid-jsdoc": "off",
344 // Allow vars to be declared anywhere in the scope.
345 "vars-on-top": "off",
346 // Disallow Yoda conditions (where literal value comes first).
349 // And these are the rules that haven't been discussed so far, and that are
350 // disabled for now until we introduce them, one at a time.
352 // Require for-in loops to have an if statement.
353 "guard-for-in": "off",
354 // disallow the use of alert, confirm, and prompt
356 // disallow comparisons to null without a type-checking operator
358 // disallow overwriting functions written as function declarations
359 "no-func-assign": "off",
360 // disallow function or variable declarations in nested blocks
361 "no-inner-declarations": "off",
362 // disallow invalid regular expression strings in the RegExp constructor
363 "no-invalid-regexp": "off",
364 // disallow irregular whitespace outside of strings and comments
365 "no-irregular-whitespace": "off",
366 // disallow labels that share a name with a variable
367 "no-label-var": "off",
368 // disallow unnecessary nested blocks
369 "no-lone-blocks": "off",
370 // disallow creation of functions within loops
371 "no-loop-func": "off",
372 // disallow use of new operator when not part of the assignment or
375 // disallow use of new operator for Function object
376 "no-new-func": "off",
377 // disallow use of the Object constructor
378 "no-new-object": "off",
379 // disallows creating new instances of String,Number, and Boolean
380 "no-new-wrappers": "off",
381 // disallow the use of object properties of the global object (Math and
382 // JSON) as functions
383 "no-obj-calls": "off",
384 // disallow use of octal escape sequences in string literals, such as
385 // var foo = "Copyright \251";
386 "no-octal-escape": "off",
387 // disallow use of undefined when initializing variables
388 "no-undef-init": "off",
389 // disallow usage of expressions in statement position
390 "no-unused-expressions": "off",
391 // disallow unnecessary concatenation of literals or template literals
392 "no-useless-concat": "off",
393 // disallow use of void operator
395 // require assignment operator shorthand where possible or prohibit it
397 "operator-assignment": "off",