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