3 const xpcshellTestConfig = require("eslint-plugin-mozilla/lib/configs/xpcshell-test.js");
4 const browserTestConfig = require("eslint-plugin-mozilla/lib/configs/browser-test.js");
5 const mochitestTestConfig = require("eslint-plugin-mozilla/lib/configs/mochitest-test.js");
6 const chromeTestConfig = require("eslint-plugin-mozilla/lib/configs/chrome-test.js");
9 * Some configurations have overrides, which can't be specified within overrides,
10 * so we need to remove them.
12 function removeOverrides(config) {
14 delete config.overrides;
18 const xpcshellTestPaths = [
23 const browserTestPaths = [
24 "**/test*/**/browser/",
27 const mochitestTestPaths = [
28 "**/test*/mochitest/",
31 const chromeTestPaths = [
36 // New rules and configurations should generally be added in
37 // tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js to
38 // allow external repositories that use the plugin to pick them up as well.
40 "plugin:mozilla/recommended"
51 "js/src/builtin/**/*.js",
52 "js/src/shell/**/*.js"
55 // Curly brackets are required for all the tree via recommended.js,
56 // however these files aren't auto-fixable at the moment.
60 // TODO: Bug 1515949. Enable no-undef for gfx/
61 "files": "gfx/layers/apz/test/mochitest/**",
66 ...removeOverrides(xpcshellTestConfig),
67 "files": xpcshellTestPaths.map(path => `${path}**`),
68 "excludedFiles": "devtools/**"
70 // If it is an xpcshell head file, we turn off global unused variable checks, as it
71 // would require searching the other test files to know if they are used or not.
72 // This would be expensive and slow, and it isn't worth it for head files.
73 // We could get developers to declare as exported, but that doesn't seem worth it.
74 "files": xpcshellTestPaths.map(path => `${path}head*.js`),
76 "no-unused-vars": ["error", {
83 "files": browserTestPaths.map(path => `${path}**`),
84 "excludedFiles": "devtools/**"
86 ...removeOverrides(mochitestTestConfig),
87 "files": mochitestTestPaths.map(path => `${path}**`),
90 "security/manager/ssl/tests/mochitest/browser/**",
91 "testing/mochitest/**",
94 ...removeOverrides(chromeTestConfig),
95 "files": chromeTestPaths.map(path => `${path}**`),
101 // Ideally we wouldn't be using the simpletest env here, but our uses of
102 // js files mean we pick up everything from the global scope, which could
103 // be any one of a number of html files. So we just allow the basics...
104 "mozilla/simpletest": true,
107 ...mochitestTestPaths.map(path => `${path}/**/*.js`),
108 ...chromeTestPaths.map(path => `${path}/**/*.js`),
112 "extensions/permissions/test/**",
113 "extensions/spellcheck/**",
114 "extensions/universalchardet/tests/**",
117 "mozilla/reject-importGlobalProperties": "off",
118 "mozilla/use-default-preference-values": "off",
119 "mozilla/use-services": "off",
120 "no-array-constructor": "off",
122 "no-unused-vars": "off",
123 "no-redeclare": "off",
124 "no-global-assign": "off",
128 "netwerk/cookie/test/browser/**",
129 "netwerk/test/browser/**",
130 "netwerk/test/mochitests/**",
131 "netwerk/test/unit*/**",
134 "mozilla/consistent-if-bracing": "off",
135 "mozilla/reject-importGlobalProperties": "off",
136 "mozilla/no-arbitrary-setTimeout": "off",
137 "mozilla/no-define-cc-etc": "off",
138 "mozilla/use-default-preference-values": "off",
139 "mozilla/use-services": "off",
140 "consistent-return": "off",
141 "no-array-constructor": "off",
143 "no-global-assign": "off",
144 "no-nested-ternary": "off",
145 "no-new-wrappers": "off",
146 "no-redeclare": "off",
147 "no-return-await": "off",
148 "no-sequences": "off",
150 "no-throw-literal": "off",
152 "no-unreachable": "off",
153 "no-unused-vars": "off",
154 "no-useless-return": "off",
161 "object-shorthand": "off",
162 "mozilla/avoid-removeChild": "off",
163 "mozilla/consistent-if-bracing": "off",
164 "mozilla/reject-importGlobalProperties": "off",
165 "mozilla/no-arbitrary-setTimeout": "off",
166 "mozilla/no-define-cc-etc": "off",
167 "mozilla/use-chromeutils-generateqi": "off",
168 "mozilla/use-default-preference-values": "off",
169 "mozilla/use-includes-instead-of-indexOf": "off",
170 "mozilla/use-services": "off",
171 "mozilla/use-ownerGlobal": "off",
173 "consistent-return": "off",
174 "no-array-constructor": "off",
176 "no-cond-assign": "off",
177 "no-extra-boolean-cast": "off",
179 "no-func-assign": "off",
180 "no-global-assign": "off",
181 "no-implied-eval": "off",
182 "no-lonely-if": "off",
183 "no-nested-ternary": "off",
184 "no-new-wrappers": "off",
185 "no-redeclare": "off",
186 "no-restricted-globals": "off",
187 "no-return-await": "off",
188 "no-sequences": "off",
189 "no-throw-literal": "off",
190 "no-useless-concat": "off",
192 "no-unreachable": "off",
193 "no-unsanitized/method": "off",
194 "no-unsanitized/property": "off",
195 "no-unsafe-negation": "off",
196 "no-unused-vars": "off",
197 "no-useless-return": "off",
203 "dom/base/test/unit/test_serializers_entities*.js",
204 "dom/base/test/unit_ipc/**",
205 "dom/base/test/jsmodules/**",
214 "dom/media/tests/**",
215 "dom/media/webaudio/**",
216 "dom/media/webspeech/**",
217 "dom/messagechannel/**",
221 "dom/performance/**",
224 "dom/security/test/cors/**",
225 "dom/security/test/csp/**",
226 "dom/security/test/general/**",
227 "dom/security/test/mixedcontentblocker/**",
228 "dom/security/test/sri/**",
229 "dom/serviceworkers/**",
231 "dom/tests/mochitest/**",
245 "consistent-return": "off",
246 "mozilla/avoid-removeChild": "off",
247 "mozilla/consistent-if-bracing": "off",
248 "mozilla/no-arbitrary-setTimeout": "off",
249 "mozilla/no-compare-against-boolean-literals": "off",
250 "mozilla/no-define-cc-etc": "off",
251 "mozilla/reject-importGlobalProperties": "off",
252 "mozilla/use-cc-etc": "off",
253 "mozilla/use-chromeutils-generateqi": "off",
254 "mozilla/use-chromeutils-import": "off",
255 "mozilla/use-includes-instead-of-indexOf": "off",
256 "mozilla/use-ownerGlobal": "off",
257 "mozilla/use-services": "off",
258 "no-array-constructor": "off",
260 "no-cond-assign": "off",
261 "no-control-regex": "off",
262 "no-debugger": "off",
263 "no-else-return": "off",
266 "no-func-assign": "off",
267 "no-global-assign": "off",
268 "no-implied-eval": "off",
269 "no-lone-blocks": "off",
270 "no-lonely-if": "off",
271 "no-nested-ternary": "off",
272 "no-new-object": "off",
273 "no-new-wrappers": "off",
275 "no-redeclare": "off",
276 "no-return-await": "off",
277 "no-restricted-globals": "off",
278 "no-self-assign": "off",
279 "no-self-compare": "off",
280 "no-sequences": "off",
282 "no-shadow-restricted-names": "off",
283 "no-sparse-arrays": "off",
284 "no-throw-literal": "off",
285 "no-unreachable": "off",
286 "no-unsanitized/method": "off",
287 "no-unsanitized/property": "off",
289 "no-unused-vars": "off",
290 "no-useless-call": "off",
291 "no-useless-concat": "off",
292 "no-useless-return": "off",
297 "browser/components/extensions/ExtensionControlledPopup.jsm",
298 "browser/components/extensions/test/browser/browser_ext_devtools_network.js",
299 "browser/components/extensions/test/browser/browser_ext_tabs_zoom.js",
300 "browser/components/places/tests/browser/browser_bookmarksProperties.js",
301 "browser/components/preferences/in-content/tests/browser_extension_controlled.js",
302 "browser/extensions/formautofill/FormAutofillParent.jsm",
303 "browser/tools/mozscreenshots/head.js",
304 "devtools/client/aboutdebugging/test/browser/helper-addons.js",
305 "devtools/client/inspector/animation/animation.js",
306 "devtools/client/inspector/changes/ChangesView.js",
307 "devtools/client/inspector/markup/test/helper_screenshot_node.js",
308 "devtools/client/performance/modules/widgets/graphs.js",
309 "devtools/client/scratchpad/scratchpad.js",
310 "devtools/client/webconsole/webconsole-wrapper.js",
311 "devtools/server/tests/unit/test_breakpoint-17.js",
312 "devtools/shared/adb/adb-process.js",
313 "devtools/shared/fronts/webconsole.js",
314 "dom/l10n/tests/mochitest/document_l10n/non-system-principal/test.html",
315 "dom/payments/test/test_basiccard.html",
316 "dom/payments/test/test_bug1478740.html",
317 "dom/payments/test/test_canMakePayment.html",
318 "dom/payments/test/test_closePayment.html",
319 "dom/payments/test/test_showPayment.html",
320 "dom/tests/browser/browser_persist_cookies.js",
321 "dom/tests/browser/browser_persist_mixed_content_image.js",
322 "netwerk/test/unit/test_http2-proxy.js",
323 "toolkit/components/contentprefs/ContentPrefService2.jsm",
324 "toolkit/components/extensions/ExtensionShortcuts.jsm",
325 "toolkit/components/extensions/ExtensionTestCommon.jsm",
326 "toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_getCurrent.js",
327 "toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js",
328 "toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js",
329 "toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js",
330 "toolkit/components/satchel/FormHistory.jsm",
331 "toolkit/content/tests/browser/browser_findbar.js",
332 "toolkit/modules/NewTabUtils.jsm",
333 "toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js",
334 "toolkit/mozapps/extensions/test/browser/head.js",
337 "no-async-promise-executor": "off",