Bug 1557368 [wpt PR 16856] - Update error type test for attachInternals(), a=testonly
[gecko.git] / .eslintrc.js
blob069a6474c56bc0ffe6e0f43d6a9048ebf4633eb6
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   // The html plugin is enabled via a command line option on eslint. To avoid
46   // bad interactions with the xml preprocessor in eslint-plugin-mozilla, we
47   // turn off processing of the html plugin for .xml files.
48   "settings": {
49     "html/xml-extensions": [ ".xhtml" ]
50   },
52   "overrides": [{
53     // eslint-plugin-html handles eol-last slightly different - it applies to
54     // each set of script tags, so we turn it off here.
55     "files": "**/*.*html",
56     "rules": {
57       "eol-last": "off",
58     }
59   }, {
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.
64     "files": [
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"
70     ],
71     "env": {
72       "mozilla/browser-window": true
73     }
74   }, {
75     // TODO: Bug 1515949. Enable no-undef for gfx/
76     "files": "gfx/layers/apz/test/mochitest/**",
77     "rules": {
78       "no-undef": "off",
79     }
80   }, {
81     ...removeOverrides(xpcshellTestConfig),
82     "files": xpcshellTestPaths.map(path => `${path}**`),
83     "excludedFiles": "devtools/**"
84   }, {
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     "rules": {
92       "no-unused-vars": ["error", {
93         "args": "none",
94         "vars": "local",
95       }],
96     },
97   }, {
98     ...browserTestConfig,
99     "files": browserTestPaths.map(path => `${path}**`),
100     "excludedFiles": "devtools/**"
101   }, {
102     ...removeOverrides(mochitestTestConfig),
103     "files": mochitestTestPaths.map(path => `${path}**`),
104     "excludedFiles": [
105       "devtools/**",
106       "security/manager/ssl/tests/mochitest/browser/**",
107       "testing/mochitest/**",
108     ],
109   }, {
110     ...removeOverrides(chromeTestConfig),
111     "files": chromeTestPaths.map(path => `${path}**`),
112     "excludedFiles": [
113       "devtools/**",
114     ],
115   }, {
116     "env": {
117       // Ideally we wouldn't be using the simpletest env here, but our uses of
118       // js files mean we pick up everything from the global scope, which could
119       // be any one of a number of html files. So we just allow the basics...
120       "mozilla/simpletest": true,
121     },
122     "files": [
123       ...mochitestTestPaths.map(path => `${path}/**/*.js`),
124       ...chromeTestPaths.map(path => `${path}/**/*.js`),
125     ],
126   }, {
127     "files": [
128       "extensions/permissions/test/**",
129       "extensions/spellcheck/**",
130       "extensions/universalchardet/tests/**",
131     ],
132     "rules": {
133       "mozilla/reject-importGlobalProperties": "off",
134       "mozilla/use-default-preference-values": "off",
135       "mozilla/use-services": "off",
136       "no-array-constructor": "off",
137       "no-undef": "off",
138       "no-unused-vars": "off",
139       "no-redeclare": "off",
140       "no-global-assign": "off",
142       // Not enabling the rules below for now pending prettier roll-out.
143       "brace-style": "off",
144       "comma-dangle": "off",
145       "linebreak-style": "off",
146       "no-tabs": "off",
147       "no-mixed-spaces-and-tabs": "off",
148       "no-multi-spaces": "off",
149       "no-trailing-spaces": "off",
150       "padded-blocks": "off",
151       "quotes": "off",
152       "semi": "off",
153       "space-infix-ops": "off",
154     }
155   }, {
156     "files": [
157       "image/**",
158     ],
159     "rules": {
160       "mozilla/consistent-if-bracing": "off",
161       "mozilla/use-chromeutils-generateqi": "off",
162       "mozilla/use-services": "off",
163       "no-array-constructor": "off",
164       "no-implied-eval": "off",
165       "no-redeclare": "off",
166       "no-self-assign": "off",
167       "no-throw-literal": "off",
168       "no-undef": "off",
169       "no-unneeded-ternary": "off",
170       "no-unused-vars": "off",
172       // Not enabling the rules below for now pending prettier roll-out.
173       "brace-style": "off",
174       "comma-dangle": "off",
175       "comma-spacing": "off",
176       "key-spacing": "off",
177       "keyword-spacing": "off",
178       "no-extra-semi": "off",
179       "no-tabs": "off",
180       "no-mixed-spaces-and-tabs": "off",
181       "no-multi-spaces": "off",
182       "no-trailing-spaces": "off",
183       "padded-blocks": "off",
184       "quotes": "off",
185       "semi": "off",
186       "space-before-function-paren": "off",
187       "space-infix-ops": "off",
188     }
189   }, {
190     "files": [
191       "netwerk/cookie/test/browser/**",
192       "netwerk/test/browser/**",
193       "netwerk/test/mochitests/**",
194       "netwerk/test/unit*/**",
195     ],
196     "rules": {
197       "object-shorthand": "off",
198       "mozilla/consistent-if-bracing": "off",
199       "mozilla/reject-importGlobalProperties": "off",
200       "mozilla/no-arbitrary-setTimeout": "off",
201       "mozilla/no-define-cc-etc": "off",
202       "mozilla/no-useless-parameters": "off",
203       "mozilla/no-useless-run-test": "off",
204       "mozilla/use-chromeutils-generateqi": "off",
205       "mozilla/use-chromeutils-import": "off",
206       "mozilla/use-default-preference-values": "off",
207       "mozilla/use-services": "off",
208       "consistent-return": "off",
209       "no-array-constructor": "off",
210       "no-extra-boolean-cast": "off",
211       "no-eval": "off",
212       "no-else-return": "off",
213       "no-global-assign": "off",
214       "no-lonely-if": "off",
215       "no-nested-ternary": "off",
216       "no-new-wrappers": "off",
217       "no-redeclare": "off",
218       "no-return-await": "off",
219       "no-sequences": "off",
220       "no-shadow": "off",
221       "no-throw-literal": "off",
222       "no-undef": "off",
223       "no-unreachable": "off",
224       "no-unused-vars": "off",
225       "no-useless-return": "off",
227       // Not enabling the rules below for now pending prettier roll-out.
228       "arrow-spacing": "off",
229       "block-spacing": "off",
230       "brace-style": "off",
231       "comma-dangle": "off",
232       "comma-spacing": "off",
233       "comma-style": "off",
234       "eol-last": "off",
235       "func-call-spacing": "off",
236       "generator-star-spacing": "off",
237       "key-spacing": "off",
238       "keyword-spacing": "off",
239       "no-extra-semi": "off",
240       "no-tabs": "off",
241       "no-mixed-spaces-and-tabs": "off",
242       "no-multi-spaces": "off",
243       "no-trailing-spaces": "off",
244       "no-whitespace-before-property": "off",
245       "padded-blocks": "off",
246       "quotes": "off",
247       "rest-spread-spacing": "off",
248       "semi": "off",
249       "space-before-blocks": "off",
250       "space-before-function-paren": "off",
251       "space-infix-ops": "off",
252       "space-unary-ops": "off",
253       "spaced-comment": "off",
254     }
255   }, {
256     "files": [
257       "layout/**",
258     ],
259     "rules": {
260       "object-shorthand": "off",
261       "mozilla/avoid-removeChild": "off",
262       "mozilla/consistent-if-bracing": "off",
263       "mozilla/reject-importGlobalProperties": "off",
264       "mozilla/no-arbitrary-setTimeout": "off",
265       "mozilla/no-define-cc-etc": "off",
266       "mozilla/no-useless-parameters": "off",
267       "mozilla/no-useless-run-test": "off",
268       "mozilla/use-chromeutils-generateqi": "off",
269       "mozilla/use-chromeutils-import": "off",
270       "mozilla/use-default-preference-values": "off",
271       "mozilla/use-includes-instead-of-indexOf": "off",
272       "mozilla/use-services": "off",
273       "mozilla/use-ownerGlobal": "off",
274       "complexity": "off",
275       "consistent-return": "off",
276       "dot-notation": "off",
277       "no-array-constructor": "off",
278       "no-caller": "off",
279       "no-cond-assign": "off",
280       "no-extra-boolean-cast": "off",
281       "no-eval": "off",
282       "no-else-return": "off",
283       "no-func-assign": "off",
284       "no-global-assign": "off",
285       "no-implied-eval": "off",
286       "no-lonely-if": "off",
287       "no-nested-ternary": "off",
288       "no-new-wrappers": "off",
289       "no-redeclare": "off",
290       "no-restricted-globals": "off",
291       "no-return-await": "off",
292       "no-sequences": "off",
293       "no-throw-literal": "off",
294       "no-useless-concat": "off",
295       "no-undef": "off",
296       "no-unreachable": "off",
297       "no-unsanitized/method": "off",
298       "no-unsanitized/property": "off",
299       "no-unsafe-negation": "off",
300       "no-unused-vars": "off",
301       "no-useless-return": "off",
303       // Not enabling the rules below for now pending prettier roll-out.
304       "arrow-spacing": "off",
305       "block-spacing": "off",
306       "brace-style": "off",
307       "comma-dangle": "off",
308       "comma-spacing": "off",
309       "comma-style": "off",
310       "eol-last": "off",
311       "func-call-spacing": "off",
312       "generator-star-spacing": "off",
313       "linebreak-style": "off",
314       "key-spacing": "off",
315       "keyword-spacing": "off",
316       "no-extra-semi": "off",
317       "no-tabs": "off",
318       "no-mixed-spaces-and-tabs": "off",
319       "no-multi-spaces": "off",
320       "no-trailing-spaces": "off",
321       "no-unexpected-multiline": "off",
322       "no-whitespace-before-property": "off",
323       "padded-blocks": "off",
324       "quotes": "off",
325       "rest-spread-spacing": "off",
326       "semi": "off",
327       "space-before-blocks": "off",
328       "space-before-function-paren": "off",
329       "space-infix-ops": "off",
330       "space-unary-ops": "off",
331       "spaced-comment": "off",
332     }
333   }, {
334     "files": [
335       "dom/animation/**",
336       "dom/base/test/*.*",
337       "dom/base/test/unit/test_serializers_entities*.js",
338       "dom/base/test/unit_ipc/**",
339       "dom/base/test/jsmodules/**",
340       "dom/base/*.*",
341       "dom/canvas/**",
342       "dom/encoding/**",
343       "dom/events/**",
344       "dom/fetch/**",
345       "dom/file/**",
346       "dom/html/**",
347       "dom/jsurl/**",
348       "dom/media/tests/**",
349       "dom/media/webaudio/**",
350       "dom/media/webspeech/**",
351       "dom/messagechannel/**",
352       "dom/midi/**",
353       "dom/network/**",
354       "dom/payments/**",
355       "dom/performance/**",
356       "dom/permission/**",
357       "dom/quota/**",
358       "dom/security/test/cors/**",
359       "dom/security/test/csp/**",
360       "dom/security/test/general/**",
361       "dom/security/test/mixedcontentblocker/**",
362       "dom/security/test/sri/**",
363       "dom/serviceworkers/**",
364       "dom/smil/**",
365       "dom/tests/mochitest/**",
366       "dom/u2f/**",
367       "dom/vr/**",
368       "dom/webauthn/**",
369       "dom/webgpu/**",
370       "dom/websocket/**",
371       "dom/workers/**",
372       "dom/worklet/**",
373       "dom/xbl/**",
374       "dom/xml/**",
375       "dom/xslt/**",
376       "dom/xul/**",
377     ],
378     "rules": {
379       "consistent-return": "off",
380       "dot-notation": "off",
381       "object-shorthand": "off",
382       "mozilla/avoid-removeChild": "off",
383       "mozilla/consistent-if-bracing": "off",
384       "mozilla/no-arbitrary-setTimeout": "off",
385       "mozilla/no-compare-against-boolean-literals": "off",
386       "mozilla/no-define-cc-etc": "off",
387       "mozilla/no-useless-parameters": "off",
388       "mozilla/no-useless-run-test": "off",
389       "mozilla/reject-importGlobalProperties": "off",
390       "mozilla/use-cc-etc": "off",
391       "mozilla/use-chromeutils-generateqi": "off",
392       "mozilla/use-chromeutils-import": "off",
393       "mozilla/use-includes-instead-of-indexOf": "off",
394       "mozilla/use-ownerGlobal": "off",
395       "mozilla/use-services": "off",
396       "no-array-constructor": "off",
397       "no-caller": "off",
398       "no-cond-assign": "off",
399       "no-control-regex": "off",
400       "no-debugger": "off",
401       "no-else-return": "off",
402       "no-empty": "off",
403       "no-eval": "off",
404       "no-extra-boolean-cast": "off",
405       "no-func-assign": "off",
406       "no-global-assign": "off",
407       "no-implied-eval": "off",
408       "no-lone-blocks": "off",
409       "no-lonely-if": "off",
410       "no-nested-ternary": "off",
411       "no-new-object": "off",
412       "no-new-wrappers": "off",
413       "no-octal": "off",
414       "no-redeclare": "off",
415       "no-return-await": "off",
416       "no-restricted-globals": "off",
417       "no-self-assign": "off",
418       "no-self-compare": "off",
419       "no-sequences": "off",
420       "no-shadow": "off",
421       "no-shadow-restricted-names": "off",
422       "no-sparse-arrays": "off",
423       "no-throw-literal": "off",
424       "no-unneeded-ternary": "off",
425       "no-unreachable": "off",
426       "no-unsanitized/method": "off",
427       "no-unsanitized/property": "off",
428       "no-undef": "off",
429       "no-unused-vars": "off",
430       "no-useless-call": "off",
431       "no-useless-concat": "off",
432       "no-useless-return": "off",
433       "no-with": "off",
435       // Not enabling the rules below for now pending prettier roll-out.
436       "arrow-spacing": "off",
437       "block-spacing": "off",
438       "brace-style": "off",
439       "comma-dangle": "off",
440       "comma-spacing": "off",
441       "comma-style": "off",
442       "computed-property-spacing": "off",
443       "eol-last": "off",
444       "func-call-spacing": "off",
445       "generator-star-spacing": "off",
446       "linebreak-style": "off",
447       "key-spacing": "off",
448       "keyword-spacing": "off",
449       "no-extra-semi": "off",
450       "no-tabs": "off",
451       "no-mixed-spaces-and-tabs": "off",
452       "no-multi-spaces": "off",
453       "no-trailing-spaces": "off",
454       "no-unexpected-multiline": "off",
455       "no-whitespace-before-property": "off",
456       "padded-blocks": "off",
457       "quotes": "off",
458       "rest-spread-spacing": "off",
459       "semi": "off",
460       "space-before-blocks": "off",
461       "space-before-function-paren": "off",
462       "space-infix-ops": "off",
463       "space-unary-ops": "off",
464       "spaced-comment": "off",
465     }
466   }]