Bug 1851050 [wpt PR 41749] - Fix select.add() with optgroups, a=testonly
[gecko.git] / .eslintrc-test-paths.js
blobfe3822f661bb7f44ddf75a3bffda4b89b8206445
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/. */
5 "use strict";
7 /* eslint-env node */
9 // The `*testPaths` defined below for test paths are the main path formats we
10 // prefer to support for tests as they are commonly used across the tree.
12 // We prefer the tests to be in named directories as this makes it easier
13 // to identify the types of tests developers are working with. Additionally,
14 // it is not possible to scope ESLint rules to individual files based on .ini
15 // files without a build step that would break editors, or an expensive loading
16 // cycle.
18 // Please do not add more cases of multiple test types in a single
19 // directory. This may cause ESLint rules to be incorrectly applied to the wrong
20 // tests, leading to false negatives. It could cause the wrong sets of globals
21 // to be defined in the scope, causing false positives when checking for no
22 // undefined variables.
24 // See https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint.html#i-m-adding-tests-how-do-i-set-up-the-right-configuration
25 // for more information.
27 const browserTestPaths = ["**/test*/**/browser*/"];
29 const chromeTestPaths = ["**/test*/chrome/"];
31 const mochitestTestPaths = [
32   // Note: we do not want to match testing/mochitest as that would apply
33   // too many globals for that directory.
34   "**/test/mochitest*/",
35   "**/tests/mochitest*/",
36   "testing/mochitest/tests/SimpleTest/",
37   "testing/mochitest/tests/Harness_sanity/",
40 const xpcshellTestPaths = [
41   "**/test*/unit*/**/",
42   "**/test*/*/unit*/",
43   "**/test*/xpcshell/**/",
46 // NOTE: Before adding to the list below, please see the note at the top
47 // of the file.
49 const extraXpcshellTestPaths = [
50   "devtools/platform/tests/xpcshell/",
51   "dom/file/tests/",
52   "dom/ipc/tests/",
53   "intl/benchmarks/",
54   "intl/l10n/test/",
55   "ipc/testshell/tests/",
56   "memory/replace/dmd/test/",
57   "netwerk/test/httpserver/test/",
58   "testing/modules/tests/xpcshell/",
59   "toolkit/components/backgroundhangmonitor/tests/",
60   "toolkit/components/downloads/test/data/",
61   "toolkit/components/mozintl/test/",
62   "toolkit/components/places/tests/",
63   "toolkit/components/places/tests/bookmarks/",
64   "toolkit/components/places/tests/expiration/",
65   "toolkit/components/places/tests/favicons/",
66   "toolkit/components/places/tests/history/",
67   "toolkit/components/places/tests/legacy/",
68   "toolkit/components/places/tests/migration/",
69   "toolkit/components/places/tests/queries/",
70   "toolkit/components/thumbnails/test/",
71   "toolkit/modules/tests/modules/",
72   "toolkit/mozapps/update/tests/data/",
73   "toolkit/profile/xpcshell/",
74   "toolkit/xre/test/",
75   "widget/headless/tests/",
78 // NOTE: Before adding to the list below, please see the note at the top
79 // of the file.
81 const extraBrowserTestPaths = [
82   "dom/ipc/tests/",
83   "toolkit/components/thumbnails/test/",
84   "toolkit/xre/test/",
85   "browser/base/content/test/about/",
86   "browser/base/content/test/alerts/",
87   "browser/base/content/test/backforward/",
88   "browser/base/content/test/caps/",
89   "browser/base/content/test/captivePortal/",
90   "browser/base/content/test/contentTheme/",
91   "browser/base/content/test/contextMenu/",
92   "browser/base/content/test/favicons/",
93   "browser/base/content/test/forms/",
94   "browser/base/content/test/fullscreen/",
95   "browser/base/content/test/general/",
96   "browser/base/content/test/gesture/",
97   "browser/base/content/test/historySwipeAnimation/",
98   "browser/base/content/test/keyboard/",
99   "browser/base/content/test/menubar/",
100   "browser/base/content/test/metaTags/",
101   "browser/base/content/test/notificationbox/",
102   "browser/base/content/test/outOfProcess/",
103   "browser/base/content/test/pageActions/",
104   "browser/base/content/test/pageStyle/",
105   "browser/base/content/test/pageinfo/",
106   "browser/base/content/test/performance/",
107   "browser/base/content/test/permissions/",
108   "browser/base/content/test/plugins/",
109   "browser/base/content/test/popupNotifications/",
110   "browser/base/content/test/popups/",
111   "browser/base/content/test/privateBrowsing/",
112   "browser/base/content/test/protectionsUI/",
113   "browser/base/content/test/referrer/",
114   "browser/base/content/test/sanitize/",
115   "browser/base/content/test/sidebar/",
116   "browser/base/content/test/siteIdentity/",
117   "browser/base/content/test/startup/",
118   "browser/base/content/test/static/",
119   "browser/base/content/test/statuspanel/",
120   "browser/base/content/test/sync/",
121   "browser/base/content/test/tabMediaIndicator/",
122   "browser/base/content/test/tabPrompts/",
123   "browser/base/content/test/tabcrashed/",
124   "browser/base/content/test/tabdialogs/",
125   "browser/base/content/test/tabs/",
126   "browser/base/content/test/touch/",
127   "browser/base/content/test/utilityOverlay/",
128   "browser/base/content/test/webextensions/",
129   "browser/base/content/test/webrtc/",
130   "browser/base/content/test/zoom/",
131   "browser/components/customizableui/test/",
132   "browser/components/pocket/test/",
133   "browser/components/preferences/tests/",
134   "browser/components/safebrowsing/content/test/",
135   "browser/components/sessionstore/test/",
136   "browser/components/shell/test/",
137   "browser/components/touchbar/tests/",
138   "browser/components/translation/test/",
139   "browser/components/uitour/test/",
140   "browser/extensions/report-site-issue/test/browser/",
141   "browser/tools/mozscreenshots/",
142   "caps/tests/mochitest/",
143   "devtools/client/debugger/test/mochitest/",
144   "devtools/client/dom/test/",
145   "devtools/client/framework/browser-toolbox/test/",
146   "devtools/client/framework/test/",
147   "devtools/client/inspector/animation/test/",
148   "devtools/client/inspector/boxmodel/test/",
149   "devtools/client/inspector/changes/test/",
150   "devtools/client/inspector/computed/test/",
151   "devtools/client/inspector/extensions/test/",
152   "devtools/client/inspector/flexbox/test/",
153   "devtools/client/inspector/fonts/test/",
154   "devtools/client/inspector/grids/test/",
155   "devtools/client/inspector/markup/test/",
156   "devtools/client/inspector/rules/test/",
157   "devtools/client/inspector/shared/test/",
158   "devtools/client/inspector/test/",
159   "devtools/client/jsonview/test/",
160   "devtools/client/memory/test/browser/",
161   "devtools/client/netmonitor/src/har/test/",
162   "devtools/client/netmonitor/test/",
163   "devtools/client/shared/sourceeditor/test/",
164   "devtools/client/shared/test/",
165   "devtools/client/storage/test/",
166   "devtools/client/styleeditor/test/",
167   "devtools/shared/commands/inspected-window/tests/",
168   "devtools/shared/commands/inspector/tests/",
169   "devtools/shared/commands/network/tests/",
170   "devtools/shared/commands/resource/tests/",
171   "devtools/shared/commands/script/tests/",
172   "devtools/shared/commands/target-configuration/tests/",
173   "devtools/shared/commands/target/tests/",
174   "devtools/shared/commands/thread-configuration/tests/",
175   "devtools/shared/test-helpers/",
176   "docshell/test/navigation/",
177   "dom/base/test/",
178   "dom/broadcastchannel/tests/",
179   "dom/events/test/",
180   "dom/fetch/tests/",
181   "dom/html/test/",
182   "dom/indexedDB/test/",
183   "dom/ipc/tests/",
184   "dom/l10n/tests/mochitest/",
185   "dom/localstorage/test/",
186   "dom/manifest/test/",
187   "dom/midi/tests/",
188   "dom/payments/test/",
189   "dom/plugins/test/mochitest/",
190   "dom/reporting/tests/",
191   "dom/security/test/cors/",
192   "dom/security/test/csp/",
193   "dom/security/test/general/",
194   "dom/security/test/https-first/",
195   "dom/security/test/https-only/",
196   "dom/security/test/mixedcontentblocker/",
197   "dom/security/test/referrer-policy/",
198   "dom/security/test/sec-fetch/",
199   "dom/serviceworkers/test/",
200   "dom/tests/browser/",
201   "dom/url/tests/",
202   "dom/workers/test/",
203   "dom/xhr/tests/",
204   "editor/libeditor/tests/",
205   "extensions/permissions/test/",
206   "layout/base/tests/",
207   "layout/style/test/",
208   "layout/xul/test/",
209   "netwerk/test/useragent/",
210   "parser/htmlparser/tests/mochitest/",
211   "security/sandbox/test/",
212   "testing/mochitest/baselinecoverage/browser_chrome/",
213   "testing/mochitest/tests/python/files/",
214   "toolkit/components/alerts/test/",
215   "toolkit/components/mozprotocol/tests/",
216   "toolkit/components/narrate/test/",
217   "toolkit/components/pdfjs/test/",
218   "toolkit/components/pictureinpicture/tests/",
219   "toolkit/components/printing/tests/",
220   "toolkit/components/reader/test/",
221   "toolkit/components/thumbnails/test/",
222   "toolkit/components/tooltiptext/tests/",
223   "toolkit/components/windowcreator/test/",
224   "toolkit/components/windowwatcher/test/",
225   "toolkit/mozapps/extensions/test/xpinstall/",
226   "uriloader/exthandler/tests/mochitest/",
229 // NOTE: Before adding to the list below, please see the note at the top
230 // of the file.
232 const extraChromeTestPaths = [
233   "devtools/shared/security/tests/chrome/",
234   "devtools/shared/webconsole/test/chrome/",
235   "dom/base/test/",
236   "dom/battery/test/",
237   "dom/bindings/test/",
238   "dom/console/tests/",
239   "dom/encoding/test/",
240   "dom/events/test/",
241   "dom/flex/test/",
242   "dom/grid/test/",
243   "dom/html/test/",
244   "dom/html/test/forms/",
245   "dom/indexedDB/test/",
246   "dom/messagechannel/tests/",
247   "dom/network/tests/",
248   "dom/promise/tests/",
249   "dom/security/test/general/",
250   "dom/security/test/sec-fetch/",
251   "dom/serviceworkers/test/",
252   "dom/system/tests/",
253   "dom/url/tests/",
254   "dom/websocket/tests/",
255   "dom/workers/test/",
256   "dom/xul/test/",
257   "editor/composer/test/",
258   "extensions/universalchardet/tests/",
259   "gfx/layers/apz/test/mochitest/",
260   "image/test/mochitest/",
261   "layout/forms/test/",
262   "layout/generic/test/",
263   "layout/mathml/tests/",
264   "layout/svg/tests/",
265   "layout/xul/test/",
266   "toolkit/components/aboutmemory/tests/",
267   "toolkit/components/printing/tests/",
268   "toolkit/components/url-classifier/tests/mochitest/",
269   "toolkit/components/viewsource/test/",
270   "toolkit/components/windowcreator/test/",
271   "toolkit/components/windowwatcher/test/",
272   "toolkit/components/workerloader/tests/",
273   "toolkit/content/tests/widgets/",
274   "toolkit/profile/test/",
275   "widget/tests/",
276   "xpfe/appshell/test/",
279 // NOTE: Before adding to the list below, please see the note at the top
280 // of the file.
282 const extraMochitestTestPaths = [
283   "dom/file/tests/",
284   "dom/ipc/tests/",
285   "toolkit/xre/test/",
286   "accessible/tests/crashtests/",
287   "browser/components/protocolhandler/test/",
288   "caps/tests/mochitest/",
289   "docshell/test/iframesandbox/",
290   "docshell/test/navigation/",
291   "dom/abort/tests/",
292   "dom/animation/test/mozilla/",
293   "dom/animation/test/style/",
294   "dom/base/test/",
295   "dom/battery/test/",
296   "dom/bindings/test/",
297   "dom/broadcastchannel/tests/",
298   "dom/canvas/test/",
299   "dom/console/tests/",
300   "dom/credentialmanagement/tests/",
301   "dom/crypto/test/",
302   "dom/encoding/test/",
303   "dom/events/test/",
304   "dom/file/tests/",
305   "dom/filesystem/compat/tests/",
306   "dom/filesystem/tests/",
307   "dom/html/test/",
308   "dom/html/test/forms/",
309   "dom/indexedDB/test/",
310   "dom/ipc/tests/",
311   "dom/jsurl/test/",
312   "dom/localstorage/test/",
313   "dom/locks/test/",
314   "dom/manifest/test/",
315   "dom/media/mediasession/test/",
316   "dom/media/mediasource/test/",
317   "dom/media/test/",
318   "dom/media/webcodecs/test/",
319   "dom/media/webcodecs/crashtests/",
320   "dom/media/webspeech/recognition/test/",
321   "dom/media/webspeech/synth/test/",
322   "dom/messagechannel/tests/",
323   "dom/midi/tests/",
324   "dom/network/tests/",
325   "dom/payments/test/",
326   "dom/performance/tests/",
327   "dom/permission/tests/",
328   "dom/plugins/test/mochitest/",
329   "dom/promise/tests/",
330   "dom/push/test/",
331   "dom/quota/test/modules/content/",
332   "dom/reporting/tests/",
333   "dom/security/test/cors/",
334   "dom/security/test/csp/",
335   "dom/security/test/https-only/",
336   "dom/security/test/mixedcontentblocker/",
337   "dom/security/test/referrer-policy/",
338   "dom/security/test/sec-fetch/",
339   "dom/security/test/sri/",
340   "dom/serviceworkers/test/",
341   "dom/smil/test/",
342   "dom/svg/test/",
343   "dom/system/tests/",
344   "dom/u2f/tests/",
345   "dom/url/tests/",
346   "dom/webauthn/tests/",
347   "dom/websocket/tests/",
348   "dom/workers/test/",
349   "dom/worklet/tests/",
350   "dom/xhr/tests/",
351   "dom/xml/test/",
352   "dom/xul/test/",
353   "editor/composer/test/",
354   "editor/libeditor/tests/",
355   "editor/spellchecker/tests/",
356   "extensions/permissions/test/",
357   "gfx/layers/apz/test/mochitest/",
358   "image/test/mochitest/",
359   "intl/uconv/tests/",
360   "layout/base/tests/",
361   "layout/forms/test/",
362   "layout/generic/test/",
363   "layout/inspector/tests/",
364   "layout/style/test/",
365   "layout/svg/tests/",
366   "layout/tables/test/",
367   "layout/xul/test/",
368   "parser/htmlparser/tests/mochitest/",
369   "services/sync/tests/tps/",
370   "testing/mochitest/baselinecoverage/plain/",
371   "testing/mochitest/tests/python/files/",
372   "toolkit/components/alerts/test/",
373   "toolkit/components/passwordmgr/test/mochitest/",
374   "toolkit/components/prompts/test/",
375   "toolkit/components/satchel/test/",
376   "toolkit/components/url-classifier/tests/mochitest/",
377   "toolkit/components/windowcreator/test/",
378   "toolkit/components/windowwatcher/test/",
379   "toolkit/content/tests/widgets/",
380   "toolkit/xre/test/",
381   "uriloader/exthandler/tests/mochitest/",
382   "widget/tests/",
385 // Please DO NOT add more entries to the list below.
386 // Doing so may cause conflicts in ESLint rules and globals, and cause
387 // unexpected issues to be raised or missed.
388 let expectedDupePaths = new Set([
389   "caps/tests/mochitest/",
390   "docshell/test/navigation/",
391   "dom/base/test/",
392   "dom/battery/test/",
393   "dom/bindings/test/",
394   "dom/broadcastchannel/tests/",
395   "dom/console/tests/",
396   "dom/encoding/test/",
397   "dom/events/test/",
398   "dom/file/tests/",
399   "dom/indexedDB/test/",
400   "dom/ipc/tests/",
401   "dom/localstorage/test/",
402   "dom/html/test/",
403   "dom/html/test/forms/",
404   "dom/manifest/test/",
405   "dom/messagechannel/tests/",
406   "dom/midi/tests/",
407   "dom/network/tests/",
408   "dom/payments/test/",
409   "dom/plugins/test/mochitest/",
410   "dom/promise/tests/",
411   "dom/reporting/tests/",
412   "dom/security/test/cors/",
413   "dom/security/test/csp/",
414   "dom/security/test/general/",
415   "dom/security/test/https-only/",
416   "dom/security/test/mixedcontentblocker/",
417   "dom/security/test/referrer-policy/",
418   "dom/security/test/sec-fetch/",
419   "dom/serviceworkers/test/",
420   "dom/system/tests/",
421   "dom/url/tests/",
422   "dom/websocket/tests/",
423   "dom/workers/test/",
424   "dom/xhr/tests/",
425   "dom/xul/test/",
426   "editor/composer/test/",
427   "editor/libeditor/tests/",
428   "extensions/permissions/test/",
429   "gfx/layers/apz/test/mochitest/",
430   "image/test/mochitest/",
431   "layout/base/tests/",
432   "layout/forms/test/",
433   "layout/generic/test/",
434   "layout/style/test/",
435   "layout/svg/tests/",
436   "layout/xul/test/",
437   "parser/htmlparser/tests/mochitest/",
438   "testing/mochitest/tests/python/files/",
439   "toolkit/components/alerts/test/",
440   "toolkit/components/printing/tests/",
441   "toolkit/components/thumbnails/test/",
442   "toolkit/components/url-classifier/tests/mochitest/",
443   "toolkit/components/windowcreator/test/",
444   "toolkit/components/windowwatcher/test/",
445   "toolkit/content/tests/widgets/",
446   "toolkit/xre/test/",
447   "uriloader/exthandler/tests/mochitest/",
448   "widget/tests/",
450 // Please DO NOT add more paths to the list above.
452 let paths = new Set(extraXpcshellTestPaths);
453 for (let path of [
454   ...extraBrowserTestPaths,
455   ...extraChromeTestPaths,
456   ...extraMochitestTestPaths,
457 ]) {
458   if (paths.has(path) && !expectedDupePaths.has(path)) {
459     throw new Error(`
460 Unexpected directory containing different test types: ${path}
462 Please do not add new paths containing different test types. Please use
463 separate directories.
465 Having different test types in the same directory may cause ESLint rules to be
466 incorrectly applied.
468   }
469   paths.add(path);
472 module.exports = {
473   testPaths: {
474     browser: [...browserTestPaths, ...extraBrowserTestPaths],
475     chrome: [...chromeTestPaths, ...extraChromeTestPaths],
476     mochitest: [...mochitestTestPaths, ...extraMochitestTestPaths],
477     xpcshell: [...xpcshellTestPaths, ...extraXpcshellTestPaths],
478   },