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/. */
15 DebuggerNotificationObserver: true,
19 files: ["client/framework/**"],
21 "no-return-assign": "off",
26 // Allow non-camelcase so that run_test doesn't produce a warning.
34 files: ["client/framework/**"],
36 "max-nested-callbacks": "off",
40 files: ["client/framework/**", "shared/webconsole/test/chrome/*.html"],
42 "mozilla/no-aArgs": "off",
46 files: ["client/framework/test/**"],
48 "mozilla/var-only-at-top-level": "off",
52 files: ["client/framework/**"],
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", { args: "none", 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 // Cu, Cc etc... are not available in most devtools modules loaded by require.
89 // Enable the rule on JSM, test head files and some specific files.
93 "**/test/**/shared-head.js",
94 "client/debugger/test/mochitest/code_frame-script.js",
95 "client/responsive.html/browser/content.js",
96 "server/startup/content-process.js",
97 "server/startup/frame.js",
98 "shared/loader/base-loader.sys.mjs",
99 "shared/loader/browser-loader.js",
100 "shared/loader/worker-loader.js",
101 "startup/aboutdebugging-registration.js",
102 "startup/aboutdevtoolstoolbox-registration.js",
103 "startup/devtools-startup.js",
106 "mozilla/no-define-cc-etc": "off",
110 // All DevTools files should avoid relative paths.
113 // Debugger modules have a custom bundling logic which relies on relative
115 "client/debugger/src/**",
116 // `client/shared/build` contains node helpers to build the debugger and
117 // not devtools modules.
118 "client/shared/build/**",
121 "mozilla/reject-relative-requires": "error",
125 // These tests use old React. We should accept deprecated API usages
127 "client/inspector/markup/test/doc_markup_events_react_development_15.4.1.html",
128 "client/inspector/markup/test/doc_markup_events_react_development_15.4.1_jsx.html",
129 "client/inspector/markup/test/doc_markup_events_react_production_15.3.1.html",
130 "client/inspector/markup/test/doc_markup_events_react_production_15.3.1_jsx.html",
133 "react/no-deprecated": "off",
137 // These files are used in both browser and node environments,
139 "shared/compatibility/constants.js",
140 "shared/compatibility/helpers.js",
144 "mozilla/privileged": false,
145 "mozilla/specific": false,
149 // This file is only used in node environment.
150 files: ["shared/compatibility/bin/update.js"],
154 "mozilla/privileged": false,
155 "mozilla/specific": false,
160 // These are the rules that have been configured so far to match the
161 // devtools coding style.
163 // Rules from the mozilla plugin
164 "mozilla/balanced-observers": "error",
165 "mozilla/no-aArgs": "error",
167 "mozilla/reject-importGlobalProperties": ["error", "everything"],
168 "mozilla/var-only-at-top-level": "error",
170 // Rules from the React plugin
171 "react/display-name": "error",
172 "react/no-danger": "error",
173 "react/no-deprecated": "error",
174 "react/no-did-mount-set-state": "error",
175 "react/no-did-update-set-state": "error",
176 "react/no-direct-mutation-state": "error",
177 "react/no-unknown-property": "error",
178 "react/prefer-es6-class": ["off", "always"],
179 "react/prop-types": "error",
183 order: ["static-methods", "lifecycle", "everything-else", "render"],
198 "UNSAFE_componentWillMount",
200 "UNSAFE_componentWillReceiveProps",
201 "shouldComponentUpdate",
202 "UNSAFE_componentWillUpdate",
203 "componentDidUpdate",
204 "componentWillUnmount",
210 // Disallow using variables outside the blocks they are defined (especially
211 // since only let and const are used, see "no-var").
212 "block-scoped-var": "error",
213 // Require camel case names
214 camelcase: ["error", { properties: "never" }],
215 // Warn about cyclomatic complexity in functions.
216 // 20 is ESLint's default, and we want to keep it this way to prevent new highly
217 // complex functions from being introduced. However, because Mozilla's eslintrc has
218 // some other value defined, we need to override it here. See bug 1553449 for more
219 // information on complex DevTools functions that are currently excluded.
220 complexity: ["error", 20],
221 // componentDidUnmount is not a real lifecycle method, use componentWillUnmount.
222 "id-denylist": ["error", "componentDidUnmount"],
223 // Maximum depth callbacks can be nested.
224 "max-nested-callbacks": ["error", 3],
225 // Require a capital letter for constructors, only check if all new
226 // operators are followed by a capital letter. Don't warn when capitalized
227 // functions are used without the new operator.
228 "new-cap": ["error", { capIsNew: false }],
229 // Disallow empty statements. This will report an error for:
230 // try { something(); } catch (e) {}
231 // but will not report it for:
232 // try { something(); } catch (e) { /* Silencing the error because ...*/ }
233 // which is a valid use case.
235 // Disallow adding to native types
236 "no-extend-native": "error",
237 // Disallow fallthrough of case statements, except if there is a comment.
238 "no-fallthrough": "error",
239 // Disallow use of multiline strings (use template strings instead).
240 "no-multi-str": "error",
241 // Disallow usage of __proto__ property.
243 // Disallow use of assignment in return statement. It is preferable for a
244 // single line of code to have only one easily predictable effect.
245 "no-return-assign": "error",
246 // Warn about declaration of variables already declared in the outer scope.
247 // This isn't an error because it sometimes is useful to use the same name
248 // in a small helper function rather than having to come up with another
250 // Still, making this a warning can help people avoid being confused.
251 "no-shadow": "error",
252 // Disallow global and local variables that aren't used, but allow unused
253 // function arguments.
254 "no-unused-vars": ["error", { args: "none", vars: "all" }],
255 // Enforce using `let` only when variables are reassigned.
256 "prefer-const": ["error", { destructuring: "all" }],
257 // Require use of the second argument for parseInt().
259 // Require "use strict" to be defined globally in the script.
260 strict: ["error", "global"],
261 // Disallow Yoda conditions (where literal value comes first).
264 // And these are the rules that haven't been discussed so far, and that are
265 // disabled for now until we introduce them, one at a time.
267 // disallow overwriting functions written as function declarations
268 "no-func-assign": "off",
269 // disallow unnecessary nested blocks
270 "no-lone-blocks": "off",
271 // disallow unnecessary concatenation of literals or template literals
272 "no-useless-concat": "off",
273 // This rule will match any function starting with `use` which aren't
274 // necessarily in a React component. Also DevTools aren't using React hooks
275 // so this sounds unecessary.
276 "react-hooks/rules-of-hooks": "off",