Bug 1700051: part 11) Change `mozInlineSpellStatus::InitForRange` to static factory...
[gecko.git] / devtools / .eslintrc.js
blob6bfd3b9adf497e8aaacf231882d846102d3b25e6
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 "use strict";
7 module.exports = {
8 plugins: ["react"],
9 globals: {
10 exports: true,
11 isWorker: true,
12 loader: true,
13 module: true,
14 reportError: true,
15 require: true,
17 overrides: [
19 files: ["client/framework/**"],
20 rules: {
21 "no-return-assign": "off",
25 files: [
26 "client/shared/*.jsm",
27 // Allow non-camelcase so that run_test doesn't produce a warning.
28 "**/test*/**/*",
30 rules: {
31 camelcase: "off",
35 files: [
36 "client/framework/**",
37 "client/shared/*.jsm",
38 "client/shared/widgets/*.jsm",
39 "client/storage/VariablesView.jsm",
41 rules: {
42 "consistent-return": "off",
46 files: ["client/framework/**"],
47 rules: {
48 "max-nested-callbacks": "off",
52 files: [
53 "client/framework/**",
54 "client/shared/*.jsm",
55 "client/shared/widgets/*.jsm",
56 "client/storage/VariablesView.jsm",
57 "shared/webconsole/test/chrome/*.html",
59 rules: {
60 "mozilla/no-aArgs": "off",
64 files: ["client/framework/test/**"],
65 rules: {
66 "mozilla/var-only-at-top-level": "off",
70 files: [
71 "client/framework/**",
72 "client/shared/widgets/*.jsm",
73 "client/storage/VariablesView.jsm",
75 rules: {
76 "no-shadow": "off",
80 files: ["client/framework/**"],
81 rules: {
82 strict: "off",
86 // For all head*.js files, turn off no-unused-vars at a global level
87 files: ["**/head*.js"],
88 rules: {
89 "no-unused-vars": ["error", { args: "none", vars: "local" }],
93 // For all server and shared files, prevent requiring devtools/client
94 // modules.
95 files: ["server/**", "shared/**"],
96 rules: {
97 "mozilla/reject-some-requires": [
98 "error",
99 "^(resource://)?devtools/client",
102 excludedFiles: [
103 // Tests can always import anything.
104 "**/test*/**/*",
108 // Cu, Cc etc... are not available in most devtools modules loaded by require.
109 files: ["**"],
110 excludedFiles: [
111 // Enable the rule on JSM, test head files and some specific files.
112 "**/*.jsm",
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",
129 rules: {
130 "mozilla/no-define-cc-etc": "off",
134 // All DevTools files should avoid relative paths.
135 files: ["**"],
136 excludedFiles: [
137 // Debugger modules have a custom bundling logic which relies on relative
138 // paths.
139 "client/debugger/**",
140 // `client/shared/build` contains node helpers to build the debugger and
141 // not devtools modules.
142 "client/shared/build/**",
144 rules: {
145 "mozilla/reject-relative-requires": "error",
149 rules: {
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",
156 // See bug 1224289.
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",
170 "react/sort-comp": [
171 "error",
173 order: ["static-methods", "lifecycle", "everything-else", "render"],
174 groups: {
175 lifecycle: [
176 "displayName",
177 "propTypes",
178 "contextTypes",
179 "childContextTypes",
180 "mixins",
181 "statics",
182 "defaultProps",
183 "constructor",
184 "getDefaultProps",
185 "getInitialState",
186 "state",
187 "getChildContext",
188 "componentWillMount",
189 "componentDidMount",
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.
219 eqeqeq: "off",
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.
225 "func-names": "off",
226 // Allow use of function declarations and expressions.
227 "func-style": "off",
228 // Only useful in a node environment.
229 "handle-callback-err": "off",
230 // Maximum depth callbacks can be nested.
231 "max-nested-callbacks": ["error", 3],
232 // Don't limit the number of parameters that can be used in a function.
233 "max-params": "off",
234 // Don't limit the maximum number of statement allowed in a function. We
235 // already have the complexity rule that's a better measurement.
236 "max-statements": "off",
237 // Require a capital letter for constructors, only check if all new
238 // operators are followed by a capital letter. Don't warn when capitalized
239 // functions are used without the new operator.
240 "new-cap": ["error", { capIsNew: false }],
241 // Allow use of bitwise operators.
242 "no-bitwise": "off",
243 // Allow using the console API.
244 "no-console": "off",
245 // Allow using constant expressions in conditions like while (true)
246 "no-constant-condition": "off",
247 // Allow use of the continue statement.
248 "no-continue": "off",
249 // Allow division operators explicitly at beginning of regular expression.
250 "no-div-regex": "off",
251 // Disallow empty statements. This will report an error for:
252 // try { something(); } catch (e) {}
253 // but will not report it for:
254 // try { something(); } catch (e) { /* Silencing the error because ...*/ }
255 // which is a valid use case.
256 "no-empty": "error",
257 // Disallow adding to native types
258 "no-extend-native": "error",
259 // Disallow fallthrough of case statements, except if there is a comment.
260 "no-fallthrough": "error",
261 // Allow comments inline after code.
262 "no-inline-comments": "off",
263 // Allow mixing regular variable and require declarations (not a node env).
264 "no-mixed-requires": "off",
265 // Disallow use of multiline strings (use template strings instead).
266 "no-multi-str": "error",
267 // Allow use of new operator with the require function.
268 "no-new-require": "off",
269 // Allow reassignment of function parameters.
270 "no-param-reassign": "off",
271 // Allow string concatenation with __dirname and __filename (not a node env).
272 "no-path-concat": "off",
273 // Allow use of unary operators, ++ and --.
274 "no-plusplus": "off",
275 // Allow using process.env (not a node environment).
276 "no-process-env": "off",
277 // Allow using process.exit (not a node environment).
278 "no-process-exit": "off",
279 // Disallow usage of __proto__ property.
280 "no-proto": "error",
281 // Disallow multiple spaces in a regular expression literal.
282 "no-regex-spaces": "off",
283 // Don't restrict usage of specified node modules (not a node environment).
284 "no-restricted-modules": "off",
285 // Prevent using some properties
286 "no-restricted-properties": [
287 "error",
289 property: "setupInParent",
290 message: "avoid child/parent communication with setupInParent",
293 // Disallow use of assignment in return statement. It is preferable for a
294 // single line of code to have only one easily predictable effect.
295 "no-return-assign": "error",
296 // Allow use of javascript: urls.
297 "no-script-url": "off",
298 // Warn about declaration of variables already declared in the outer scope.
299 // This isn't an error because it sometimes is useful to use the same name
300 // in a small helper function rather than having to come up with another
301 // random name.
302 // Still, making this a warning can help people avoid being confused.
303 "no-shadow": "error",
304 // Allow use of synchronous methods (not a node environment).
305 "no-sync": "off",
306 // Allow the use of ternary operators.
307 "no-ternary": "off",
308 // Allow dangling underscores in identifiers (for privates).
309 "no-underscore-dangle": "off",
310 // Allow use of undefined variable.
311 "no-undefined": "off",
312 // Disallow global and local variables that aren't used, but allow unused
313 // function arguments.
314 "no-unused-vars": ["error", { args: "none", vars: "all" }],
315 // Allow using variables before they are defined.
316 "no-use-before-define": "off",
317 // We use var-only-at-top-level instead of no-var as we allow top level
318 // vars.
319 "no-var": "off",
320 // Allow using TODO/FIXME comments.
321 "no-warning-comments": "off",
322 // Don't require method and property shorthand syntax for object literals.
323 // We use this in the code a lot, but not consistently, and this seems more
324 // like something to check at code review time.
325 "object-shorthand": "off",
326 // Allow more than one variable declaration per function.
327 "one-var": "off",
328 // Enforce using `let` only when variables are reassigned.
329 "prefer-const": ["error", { destructuring: "all" }],
330 // Require use of the second argument for parseInt().
331 radix: "error",
332 // Don't require to sort variables within the same declaration block.
333 // Anyway, one-var is disabled.
334 "sort-vars": "off",
335 // Require "use strict" to be defined globally in the script.
336 strict: ["error", "global"],
337 // Warn about invalid JSDoc comments.
338 // Disabled for now because of https://github.com/eslint/eslint/issues/2270
339 // The rule fails on some jsdoc comments like in:
340 // devtools/client/webconsole/old/console-output.js
341 "valid-jsdoc": "off",
342 // Allow vars to be declared anywhere in the scope.
343 "vars-on-top": "off",
344 // Disallow Yoda conditions (where literal value comes first).
345 yoda: "error",
347 // And these are the rules that haven't been discussed so far, and that are
348 // disabled for now until we introduce them, one at a time.
350 // Require for-in loops to have an if statement.
351 "guard-for-in": "off",
352 // disallow the use of alert, confirm, and prompt
353 "no-alert": "off",
354 // disallow comparisons to null without a type-checking operator
355 "no-eq-null": "off",
356 // disallow overwriting functions written as function declarations
357 "no-func-assign": "off",
358 // disallow function or variable declarations in nested blocks
359 "no-inner-declarations": "off",
360 // disallow invalid regular expression strings in the RegExp constructor
361 "no-invalid-regexp": "off",
362 // disallow irregular whitespace outside of strings and comments
363 "no-irregular-whitespace": "off",
364 // disallow labels that share a name with a variable
365 "no-label-var": "off",
366 // disallow unnecessary nested blocks
367 "no-lone-blocks": "off",
368 // disallow creation of functions within loops
369 "no-loop-func": "off",
370 // disallow use of new operator when not part of the assignment or
371 // comparison
372 "no-new": "off",
373 // disallow use of new operator for Function object
374 "no-new-func": "off",
375 // disallow use of the Object constructor
376 "no-new-object": "off",
377 // disallows creating new instances of String,Number, and Boolean
378 "no-new-wrappers": "off",
379 // disallow the use of object properties of the global object (Math and
380 // JSON) as functions
381 "no-obj-calls": "off",
382 // disallow use of octal escape sequences in string literals, such as
383 // var foo = "Copyright \251";
384 "no-octal-escape": "off",
385 // disallow use of undefined when initializing variables
386 "no-undef-init": "off",
387 // disallow usage of expressions in statement position
388 "no-unused-expressions": "off",
389 // disallow unnecessary concatenation of literals or template literals
390 "no-useless-concat": "off",
391 // disallow use of void operator
392 "no-void": "off",
393 // require assignment operator shorthand where possible or prohibit it
394 // entirely
395 "operator-assignment": "off",