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 "dom/l10n/tests/mochitest/document_l10n/non-system-principal/test.html",
298 "dom/payments/test/test_basiccard.html",
299 "dom/payments/test/test_bug1478740.html",
300 "dom/payments/test/test_canMakePayment.html",
301 "dom/payments/test/test_closePayment.html",
302 "dom/payments/test/test_showPayment.html",
303 "dom/tests/browser/browser_persist_cookies.js",
304 "dom/tests/browser/browser_persist_mixed_content_image.js",
305 "netwerk/test/unit/test_http2-proxy.js",
308 "no-async-promise-executor": "off",
312 "browser/base/content/test/chrome/test_aboutCrashed.xhtml",
313 "browser/base/content/test/chrome/test_aboutRestartRequired.xhtml",
314 "browser/base/content/test/general/browser_tab_dragdrop2_frame1.xhtml",
315 "browser/components/places/tests/chrome/test_0_bug510634.xhtml",
316 "browser/components/places/tests/chrome/test_bug1163447_selectItems_through_shortcut.xhtml",
317 "browser/components/places/tests/chrome/test_0_bug510634.xhtml",
318 "browser/components/places/tests/chrome/test_bug1163447_selectItems_through_shortcut.xhtml",
319 "browser/components/places/tests/chrome/test_bug549192.xhtml",
320 "browser/components/places/tests/chrome/test_bug549491.xhtml",
321 "browser/components/places/tests/chrome/test_selectItems_on_nested_tree.xhtml",
322 "browser/components/places/tests/chrome/test_treeview_date.xhtml",
325 "mozilla/no-arbitrary-setTimeout": "off",
326 "object-shorthand": "off",
328 "no-unused-vars": "off",
332 "accessible/tests/mochitest/actions/test_keys_menu.xhtml",
333 "accessible/tests/mochitest/elm/test_listbox.xhtml",
334 "accessible/tests/mochitest/events/test_focus_autocomplete.xhtml",
335 "accessible/tests/mochitest/events/test_focus_contextmenu.xhtml",
336 "accessible/tests/mochitest/events/test_tree.xhtml",
337 "accessible/tests/mochitest/hittest/test_zoom_tree.xhtml",
338 "accessible/tests/mochitest/name/test_general.xhtml",
339 "accessible/tests/mochitest/name/test_tree.xhtml",
340 "accessible/tests/mochitest/selectable/test_listbox.xhtml",
341 "accessible/tests/mochitest/states/test_expandable.xhtml",
342 "accessible/tests/mochitest/tree/test_button.xhtml",
343 "accessible/tests/mochitest/tree/test_tree.xhtml",
344 "accessible/tests/mochitest/treeupdate/test_contextmenu.xhtml",
345 "accessible/tests/mochitest/treeupdate/test_menu.xhtml",
348 "object-shorthand": "off",
349 "mozilla/no-compare-against-boolean-literals": "off",
350 "mozilla/use-cc-etc": "off",
351 "consistent-return": "off",
352 "no-redeclare": "off",
353 "no-sequences": "off",
355 "no-unused-vars": "off",
356 "no-useless-call": "off",
364 "editor/libeditor/tests/**",
365 "editor/spellchecker/tests/test_bug338427.html",
367 "image/test/browser/browser_image.js",
374 "security/manager/**",
376 "storage/test/unit/test_vacuum.js",
377 "taskcluster/docker/periodic-updates/scripts/**",
380 "widget/tests/test_assign_event_data.html",
383 "mozilla/prefer-boolean-length-check": "off",