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/. */
12 DebuggerNotificationObserver
: true,
17 excludedFiles
: ["**/*.sys.mjs", "**/*.worker.js"],
25 files
: ["client/framework/**"],
27 "no-return-assign": "off",
32 // Allow non-camelcase so that run_test doesn't produce a warning.
40 files
: ["client/framework/**"],
42 "max-nested-callbacks": "off",
46 files
: ["client/framework/**", "shared/webconsole/test/chrome/*.html"],
48 "mozilla/no-aArgs": "off",
52 files
: ["client/framework/test/**"],
54 "mozilla/var-only-at-top-level": "off",
58 files
: ["client/framework/**"],
64 // For all head*.js files, turn off no-unused-vars at a global level
65 files
: ["**/head*.js"],
67 "no-unused-vars": ["error", { argsIgnorePattern
: "^_", vars
: "local" }],
71 // For all server and shared files, prevent requiring devtools/client
73 files
: ["server/**", "shared/**"],
75 "mozilla/reject-some-requires": [
77 "^(resource://)?devtools/client",
81 // Tests can always import anything.
86 // All DevTools files should avoid relative paths.
89 // Debugger modules have a custom bundling logic which relies on relative
91 "client/debugger/src/**",
92 // `client/shared/build` contains node helpers to build the debugger and
93 // not devtools modules.
94 "client/shared/build/**",
97 "mozilla/reject-relative-requires": "error",
101 // These tests use old React. We should accept deprecated API usages
103 "client/inspector/markup/test/doc_markup_events_react_development_15.4.1.html",
104 "client/inspector/markup/test/doc_markup_events_react_development_15.4.1_jsx.html",
105 "client/inspector/markup/test/doc_markup_events_react_production_15.3.1.html",
106 "client/inspector/markup/test/doc_markup_events_react_production_15.3.1_jsx.html",
109 "react/no-deprecated": "off",
113 // These files are used in both browser and node environments,
115 "shared/compatibility/constants.js",
116 "shared/compatibility/helpers.js",
120 "mozilla/privileged": false,
121 "mozilla/specific": false,
125 // This file is only used in node environment.
126 files
: ["shared/compatibility/bin/update.js"],
130 "mozilla/privileged": false,
131 "mozilla/specific": false,
136 "client/inspector/markup/test/doc_markup_events_react_*_jsx.html",
146 // These are the rules that have been configured so far to match the
147 // devtools coding style.
149 // Rules from the mozilla plugin
150 "mozilla/balanced-observers": "error",
151 "mozilla/no-aArgs": "error",
153 "mozilla/reject-importGlobalProperties": ["error", "everything"],
154 "mozilla/var-only-at-top-level": "error",
156 // Rules from the React plugin
157 "react/display-name": "error",
158 "react/no-danger": "error",
159 "react/no-deprecated": "error",
160 "react/no-did-mount-set-state": "error",
161 "react/no-did-update-set-state": "error",
162 "react/no-direct-mutation-state": "error",
163 "react/no-unknown-property": "error",
164 "react/prefer-es6-class": ["off", "always"],
165 "react/prop-types": "error",
169 order
: ["static-methods", "lifecycle", "everything-else", "render"],
184 "UNSAFE_componentWillMount",
186 "UNSAFE_componentWillReceiveProps",
187 "shouldComponentUpdate",
188 "UNSAFE_componentWillUpdate",
189 "componentDidUpdate",
190 "componentWillUnmount",
196 // Disallow using variables outside the blocks they are defined (especially
197 // since only let and const are used, see "no-var").
198 "block-scoped-var": "error",
199 // Require camel case names
200 camelcase
: ["error", { properties
: "never" }],
201 // Warn about cyclomatic complexity in functions.
202 // 20 is ESLint's default, and we want to keep it this way to prevent new highly
203 // complex functions from being introduced. However, because Mozilla's eslintrc has
204 // some other value defined, we need to override it here. See bug 1553449 for more
205 // information on complex DevTools functions that are currently excluded.
206 complexity
: ["error", 20],
207 // componentDidUnmount is not a real lifecycle method, use componentWillUnmount.
208 "id-denylist": ["error", "componentDidUnmount"],
209 // Maximum depth callbacks can be nested.
210 "max-nested-callbacks": ["error", 3],
211 // Require a capital letter for constructors, only check if all new
212 // operators are followed by a capital letter. Don't warn when capitalized
213 // functions are used without the new operator.
214 "new-cap": ["error", { capIsNew
: false }],
215 // Disallow empty statements. This will report an error for:
216 // try { something(); } catch (e) {}
217 // but will not report it for:
218 // try { something(); } catch (e) { /* Silencing the error because ...*/ }
219 // which is a valid use case.
221 // Disallow adding to native types
222 "no-extend-native": "error",
223 // Disallow use of multiline strings (use template strings instead).
224 "no-multi-str": "error",
225 // Disallow usage of __proto__ property.
227 // Disallow use of assignment in return statement. It is preferable for a
228 // single line of code to have only one easily predictable effect.
229 "no-return-assign": "error",
230 // Disallow global and local variables that aren't used. Allow unused
231 // function arguments prefixed with `_`.
232 "no-unused-vars": ["error", { argsIgnorePattern
: "^_", vars
: "all" }],
233 // Enforce using `let` only when variables are reassigned.
234 "prefer-const": ["error", { destructuring
: "all" }],
235 // Require use of the second argument for parseInt().
237 // Require "use strict" to be defined globally in the script.
238 strict
: ["error", "global"],
239 // Disallow Yoda conditions (where literal value comes first).
242 // And these are the rules that haven't been discussed so far, and that are
243 // disabled for now until we introduce them, one at a time.
245 // disallow overwriting functions written as function declarations
246 "no-func-assign": "off",
247 // disallow unnecessary nested blocks
248 "no-lone-blocks": "off",
249 // disallow unnecessary concatenation of literals or template literals
250 "no-useless-concat": "off",
251 // This rule will match any function starting with `use` which aren't
252 // necessarily in a React component. Also DevTools aren't using React hooks
253 // so this sounds unecessary.
254 "react-hooks/rules-of-hooks": "off",