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 // These xbl bindings are assumed to be in the browser-window environment,
61 // we would mark it in the files, but ESLint made this more difficult with
62 // our xml processor, so we list them here. Bug 1397874 & co are working
63 // towards removing these files completely.
65 "browser/base/content/tabbrowser.xml",
66 "browser/base/content/urlbarBindings.xml",
67 "browser/components/search/content/search.xml",
68 "browser/components/translation/translation-infobar.xml",
69 "toolkit/components/prompts/content/tabprompts.xml"
72 "mozilla/browser-window": true
75 // TODO: Bug 1515949. Enable no-undef for gfx/
76 "files": "gfx/layers/apz/test/mochitest/**",
81 ...removeOverrides(xpcshellTestConfig),
82 "files": xpcshellTestPaths.map(path => `${path}**`),
83 "excludedFiles": "devtools/**"
85 // If it is an xpcshell head file, we turn off global unused variable checks, as it
86 // would require searching the other test files to know if they are used or not.
87 // This would be expensive and slow, and it isn't worth it for head files.
88 // We could get developers to declare as exported, but that doesn't seem worth it.
89 "files": xpcshellTestPaths.map(path => `${path}head*.js`),
91 "no-unused-vars": ["error", {
98 "files": browserTestPaths.map(path => `${path}**`),
99 "excludedFiles": "devtools/**"
101 ...removeOverrides(mochitestTestConfig),
102 "files": mochitestTestPaths.map(path => `${path}**`),
105 "security/manager/ssl/tests/mochitest/browser/**",
106 "testing/mochitest/**",
109 ...removeOverrides(chromeTestConfig),
110 "files": chromeTestPaths.map(path => `${path}**`),
116 // Ideally we wouldn't be using the simpletest env here, but our uses of
117 // js files mean we pick up everything from the global scope, which could
118 // be any one of a number of html files. So we just allow the basics...
119 "mozilla/simpletest": true,
122 ...mochitestTestPaths.map(path => `${path}/**/*.js`),
123 ...chromeTestPaths.map(path => `${path}/**/*.js`),
127 "extensions/permissions/test/**",
128 "extensions/spellcheck/**",
129 "extensions/universalchardet/tests/**",
132 "mozilla/reject-importGlobalProperties": "off",
133 "mozilla/use-default-preference-values": "off",
134 "mozilla/use-services": "off",
135 "no-array-constructor": "off",
137 "no-unused-vars": "off",
138 "no-redeclare": "off",
139 "no-global-assign": "off",
143 "netwerk/cookie/test/browser/**",
144 "netwerk/test/browser/**",
145 "netwerk/test/mochitests/**",
146 "netwerk/test/unit*/**",
149 "mozilla/consistent-if-bracing": "off",
150 "mozilla/reject-importGlobalProperties": "off",
151 "mozilla/no-arbitrary-setTimeout": "off",
152 "mozilla/no-define-cc-etc": "off",
153 "mozilla/use-default-preference-values": "off",
154 "mozilla/use-services": "off",
155 "consistent-return": "off",
156 "no-array-constructor": "off",
158 "no-global-assign": "off",
159 "no-nested-ternary": "off",
160 "no-new-wrappers": "off",
161 "no-redeclare": "off",
162 "no-return-await": "off",
163 "no-sequences": "off",
165 "no-throw-literal": "off",
167 "no-unreachable": "off",
168 "no-unused-vars": "off",
169 "no-useless-return": "off",
176 "object-shorthand": "off",
177 "mozilla/avoid-removeChild": "off",
178 "mozilla/consistent-if-bracing": "off",
179 "mozilla/reject-importGlobalProperties": "off",
180 "mozilla/no-arbitrary-setTimeout": "off",
181 "mozilla/no-define-cc-etc": "off",
182 "mozilla/use-chromeutils-generateqi": "off",
183 "mozilla/use-default-preference-values": "off",
184 "mozilla/use-includes-instead-of-indexOf": "off",
185 "mozilla/use-services": "off",
186 "mozilla/use-ownerGlobal": "off",
188 "consistent-return": "off",
189 "no-array-constructor": "off",
191 "no-cond-assign": "off",
192 "no-extra-boolean-cast": "off",
194 "no-func-assign": "off",
195 "no-global-assign": "off",
196 "no-implied-eval": "off",
197 "no-lonely-if": "off",
198 "no-nested-ternary": "off",
199 "no-new-wrappers": "off",
200 "no-redeclare": "off",
201 "no-restricted-globals": "off",
202 "no-return-await": "off",
203 "no-sequences": "off",
204 "no-throw-literal": "off",
205 "no-useless-concat": "off",
207 "no-unreachable": "off",
208 "no-unsanitized/method": "off",
209 "no-unsanitized/property": "off",
210 "no-unsafe-negation": "off",
211 "no-unused-vars": "off",
212 "no-useless-return": "off",
218 "dom/base/test/unit/test_serializers_entities*.js",
219 "dom/base/test/unit_ipc/**",
220 "dom/base/test/jsmodules/**",
229 "dom/media/tests/**",
230 "dom/media/webaudio/**",
231 "dom/media/webspeech/**",
232 "dom/messagechannel/**",
236 "dom/performance/**",
239 "dom/security/test/cors/**",
240 "dom/security/test/csp/**",
241 "dom/security/test/general/**",
242 "dom/security/test/mixedcontentblocker/**",
243 "dom/security/test/sri/**",
244 "dom/serviceworkers/**",
246 "dom/tests/mochitest/**",
260 "consistent-return": "off",
261 "dot-notation": "off",
262 "object-shorthand": "off",
263 "mozilla/avoid-removeChild": "off",
264 "mozilla/consistent-if-bracing": "off",
265 "mozilla/no-arbitrary-setTimeout": "off",
266 "mozilla/no-compare-against-boolean-literals": "off",
267 "mozilla/no-define-cc-etc": "off",
268 "mozilla/no-useless-parameters": "off",
269 "mozilla/no-useless-run-test": "off",
270 "mozilla/reject-importGlobalProperties": "off",
271 "mozilla/use-cc-etc": "off",
272 "mozilla/use-chromeutils-generateqi": "off",
273 "mozilla/use-chromeutils-import": "off",
274 "mozilla/use-includes-instead-of-indexOf": "off",
275 "mozilla/use-ownerGlobal": "off",
276 "mozilla/use-services": "off",
277 "no-array-constructor": "off",
279 "no-cond-assign": "off",
280 "no-control-regex": "off",
281 "no-debugger": "off",
282 "no-else-return": "off",
285 "no-extra-boolean-cast": "off",
286 "no-func-assign": "off",
287 "no-global-assign": "off",
288 "no-implied-eval": "off",
289 "no-lone-blocks": "off",
290 "no-lonely-if": "off",
291 "no-nested-ternary": "off",
292 "no-new-object": "off",
293 "no-new-wrappers": "off",
295 "no-redeclare": "off",
296 "no-return-await": "off",
297 "no-restricted-globals": "off",
298 "no-self-assign": "off",
299 "no-self-compare": "off",
300 "no-sequences": "off",
302 "no-shadow-restricted-names": "off",
303 "no-sparse-arrays": "off",
304 "no-throw-literal": "off",
305 "no-unneeded-ternary": "off",
306 "no-unreachable": "off",
307 "no-unsanitized/method": "off",
308 "no-unsanitized/property": "off",
310 "no-unused-vars": "off",
311 "no-useless-call": "off",
312 "no-useless-concat": "off",
313 "no-useless-return": "off",
318 "browser/components/extensions/ExtensionControlledPopup.jsm",
319 "browser/components/extensions/test/browser/browser_ext_devtools_network.js",
320 "browser/components/extensions/test/browser/browser_ext_tabs_zoom.js",
321 "browser/components/places/tests/browser/browser_bookmarksProperties.js",
322 "browser/components/preferences/in-content/tests/browser_extension_controlled.js",
323 "browser/extensions/formautofill/FormAutofillParent.jsm",
324 "browser/tools/mozscreenshots/head.js",
325 "devtools/client/aboutdebugging/test/browser/helper-addons.js",
326 "devtools/client/inspector/animation/animation.js",
327 "devtools/client/inspector/changes/ChangesView.js",
328 "devtools/client/inspector/markup/test/helper_screenshot_node.js",
329 "devtools/client/performance/modules/widgets/graphs.js",
330 "devtools/client/scratchpad/scratchpad.js",
331 "devtools/client/webconsole/webconsole-wrapper.js",
332 "devtools/server/tests/unit/test_breakpoint-17.js",
333 "devtools/shared/adb/adb-process.js",
334 "devtools/shared/fronts/webconsole.js",
335 "dom/l10n/tests/mochitest/document_l10n/non-system-principal/test.html",
336 "dom/payments/test/test_basiccard.html",
337 "dom/payments/test/test_bug1478740.html",
338 "dom/payments/test/test_canMakePayment.html",
339 "dom/payments/test/test_closePayment.html",
340 "dom/payments/test/test_showPayment.html",
341 "dom/tests/browser/browser_persist_cookies.js",
342 "dom/tests/browser/browser_persist_mixed_content_image.js",
343 "netwerk/test/unit/test_http2-proxy.js",
344 "toolkit/components/contentprefs/ContentPrefService2.jsm",
345 "toolkit/components/extensions/ExtensionShortcuts.jsm",
346 "toolkit/components/extensions/ExtensionTestCommon.jsm",
347 "toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_getCurrent.js",
348 "toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js",
349 "toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js",
350 "toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js",
351 "toolkit/components/satchel/FormHistory.jsm",
352 "toolkit/content/tests/browser/browser_findbar.js",
353 "toolkit/modules/NewTabUtils.jsm",
354 "toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js",
355 "toolkit/mozapps/extensions/test/browser/head.js",
358 "no-async-promise-executor": "off",