Bug 1583654 - Use the subgridToParentMap to check that the node was previously a...
[gecko.git] / .eslintrc.js
blob74f8679fc432a03de5d5f380a8bb19e13a8eb6e8
1 "use strict";
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");
8 /**
9  * Some configurations have overrides, which can't be specified within overrides,
10  * so we need to remove them.
11  */
12 function removeOverrides(config) {
13   config = {...config};
14   delete config.overrides;
15   return config;
18 const xpcshellTestPaths = [
19   "**/test*/unit*/",
20   "**/test*/xpcshell/",
23 const browserTestPaths = [
24   "**/test*/**/browser/",
27 const mochitestTestPaths = [
28   "**/test*/mochitest/",
31 const chromeTestPaths = [
32   "**/test*/chrome/",
35 module.exports = {
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.
39   "extends": [
40     "plugin:mozilla/recommended"
41   ],
42   "plugins": [
43     "mozilla"
44   ],
45   "overrides": [{
46     "files": [
47       "*.html",
48       "*.xhtml",
49       "*.xul",
50       "*.xml",
51       "js/src/builtin/**/*.js",
52       "js/src/shell/**/*.js"
53     ],
54     "rules": {
55       // Curly brackets are required for all the tree via recommended.js,
56       // however these files aren't auto-fixable at the moment.
57       "curly": "off"
58     },
59   }, {
60     // TODO: Bug 1515949. Enable no-undef for gfx/
61     "files": "gfx/layers/apz/test/mochitest/**",
62     "rules": {
63       "no-undef": "off",
64     }
65   }, {
66     ...removeOverrides(xpcshellTestConfig),
67     "files": xpcshellTestPaths.map(path => `${path}**`),
68     "excludedFiles": "devtools/**"
69   }, {
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`),
75     "rules": {
76       "no-unused-vars": ["error", {
77         "args": "none",
78         "vars": "local",
79       }],
80     },
81   }, {
82     ...browserTestConfig,
83     "files": browserTestPaths.map(path => `${path}**`),
84     "excludedFiles": "devtools/**"
85   }, {
86     ...removeOverrides(mochitestTestConfig),
87     "files": mochitestTestPaths.map(path => `${path}**`),
88     "excludedFiles": [
89       "devtools/**",
90       "security/manager/ssl/tests/mochitest/browser/**",
91       "testing/mochitest/**",
92     ],
93   }, {
94     ...removeOverrides(chromeTestConfig),
95     "files": chromeTestPaths.map(path => `${path}**`),
96     "excludedFiles": [
97       "devtools/**",
98     ],
99   }, {
100     "env": {
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,
105     },
106     "files": [
107       ...mochitestTestPaths.map(path => `${path}/**/*.js`),
108       ...chromeTestPaths.map(path => `${path}/**/*.js`),
109     ],
110   }, {
111     "files": [
112       "extensions/permissions/test/**",
113       "extensions/spellcheck/**",
114       "extensions/universalchardet/tests/**",
115     ],
116     "rules": {
117       "mozilla/reject-importGlobalProperties": "off",
118       "mozilla/use-default-preference-values": "off",
119       "mozilla/use-services": "off",
120       "no-array-constructor": "off",
121       "no-undef": "off",
122       "no-unused-vars": "off",
123       "no-redeclare": "off",
124       "no-global-assign": "off",
125     }
126   }, {
127     "files": [
128       "netwerk/cookie/test/browser/**",
129       "netwerk/test/browser/**",
130       "netwerk/test/mochitests/**",
131       "netwerk/test/unit*/**",
132     ],
133     "rules": {
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",
142       "no-eval": "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",
149       "no-shadow": "off",
150       "no-throw-literal": "off",
151       "no-undef": "off",
152       "no-unreachable": "off",
153       "no-unused-vars": "off",
154       "no-useless-return": "off",
155     }
156   }, {
157     "files": [
158       "layout/**",
159     ],
160     "rules": {
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",
172       "complexity": "off",
173       "consistent-return": "off",
174       "no-array-constructor": "off",
175       "no-caller": "off",
176       "no-cond-assign": "off",
177       "no-extra-boolean-cast": "off",
178       "no-eval": "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",
191       "no-undef": "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",
198     }
199   }, {
200     "files": [
201       "dom/animation/**",
202       "dom/base/test/*.*",
203       "dom/base/test/unit/test_serializers_entities*.js",
204       "dom/base/test/unit_ipc/**",
205       "dom/base/test/jsmodules/**",
206       "dom/base/*.*",
207       "dom/canvas/**",
208       "dom/encoding/**",
209       "dom/events/**",
210       "dom/fetch/**",
211       "dom/file/**",
212       "dom/html/**",
213       "dom/jsurl/**",
214       "dom/media/tests/**",
215       "dom/media/webaudio/**",
216       "dom/media/webspeech/**",
217       "dom/messagechannel/**",
218       "dom/midi/**",
219       "dom/network/**",
220       "dom/payments/**",
221       "dom/performance/**",
222       "dom/permission/**",
223       "dom/quota/**",
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/**",
230       "dom/smil/**",
231       "dom/tests/mochitest/**",
232       "dom/u2f/**",
233       "dom/vr/**",
234       "dom/webauthn/**",
235       "dom/webgpu/**",
236       "dom/websocket/**",
237       "dom/workers/**",
238       "dom/worklet/**",
239       "dom/xbl/**",
240       "dom/xml/**",
241       "dom/xslt/**",
242       "dom/xul/**",
243     ],
244     "rules": {
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",
259       "no-caller": "off",
260       "no-cond-assign": "off",
261       "no-control-regex": "off",
262       "no-debugger": "off",
263       "no-else-return": "off",
264       "no-empty": "off",
265       "no-eval": "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",
274       "no-octal": "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",
281       "no-shadow": "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",
288       "no-undef": "off",
289       "no-unused-vars": "off",
290       "no-useless-call": "off",
291       "no-useless-concat": "off",
292       "no-useless-return": "off",
293       "no-with": "off",
294     }
295   }, {
296     "files": [
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",
306     ],
307     "rules": {
308       "no-async-promise-executor": "off",
309     }
310   }, {
311     "files": [
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",
323     ],
324     "rules": {
325       "mozilla/no-arbitrary-setTimeout": "off",
326       "object-shorthand": "off",
327       "no-undef": "off",
328       "no-unused-vars": "off",
329     }
330   }, {
331     "files": [
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",
346     ],
347     "rules": {
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",
354       "no-shadow": "off",
355       "no-unused-vars": "off",
356       "no-useless-call": "off",
357     }
358   }, {
359     "files": [
360       "accessible/**",
361       "devtools/**",
362       "dom/**",
363       "docshell/**",
364       "editor/libeditor/tests/**",
365       "editor/spellchecker/tests/test_bug338427.html",
366       "gfx/**",
367       "image/test/browser/browser_image.js",
368       "js/src/builtin/**",
369       "layout/**",
370       "mobile/android/**",
371       "modules/**",
372       "netwerk/**",
373       "remote/**",
374       "security/manager/**",
375       "services/**",
376       "storage/test/unit/test_vacuum.js",
377       "taskcluster/docker/periodic-updates/scripts/**",
378       "testing/**",
379       "tools/**",
380       "widget/tests/test_assign_event_data.html",
381     ],
382     "rules": {
383       "mozilla/prefer-boolean-length-check": "off",
384     }
385   }]