Bug 1580545 - Convert ResponsiveUI and ResponsiveUIManager to ES6 classes. r=mtigley
[gecko.git] / .eslintrc.js
blob3d890dcfc8e9fc93d4a4a00305e41f98ec4f5e0f
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       "browser/components/extensions/ExtensionControlledPopup.jsm",
298       "browser/components/extensions/test/browser/browser_ext_devtools_network.js",
299       "browser/components/extensions/test/browser/browser_ext_tabs_zoom.js",
300       "browser/components/places/tests/browser/browser_bookmarksProperties.js",
301       "browser/components/preferences/in-content/tests/browser_extension_controlled.js",
302       "browser/extensions/formautofill/FormAutofillParent.jsm",
303       "browser/tools/mozscreenshots/head.js",
304       "devtools/client/aboutdebugging/test/browser/helper-addons.js",
305       "devtools/client/inspector/animation/animation.js",
306       "devtools/client/inspector/changes/ChangesView.js",
307       "devtools/client/inspector/markup/test/helper_screenshot_node.js",
308       "devtools/client/performance/modules/widgets/graphs.js",
309       "devtools/client/scratchpad/scratchpad.js",
310       "devtools/client/webconsole/webconsole-wrapper.js",
311       "devtools/server/tests/unit/test_breakpoint-17.js",
312       "devtools/shared/adb/adb-process.js",
313       "devtools/shared/fronts/webconsole.js",
314       "dom/l10n/tests/mochitest/document_l10n/non-system-principal/test.html",
315       "dom/payments/test/test_basiccard.html",
316       "dom/payments/test/test_bug1478740.html",
317       "dom/payments/test/test_canMakePayment.html",
318       "dom/payments/test/test_closePayment.html",
319       "dom/payments/test/test_showPayment.html",
320       "dom/tests/browser/browser_persist_cookies.js",
321       "dom/tests/browser/browser_persist_mixed_content_image.js",
322       "netwerk/test/unit/test_http2-proxy.js",
323       "toolkit/components/contentprefs/ContentPrefService2.jsm",
324       "toolkit/components/extensions/ExtensionShortcuts.jsm",
325       "toolkit/components/extensions/ExtensionTestCommon.jsm",
326       "toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_getCurrent.js",
327       "toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js",
328       "toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js",
329       "toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js",
330       "toolkit/components/satchel/FormHistory.jsm",
331       "toolkit/content/tests/browser/browser_findbar.js",
332       "toolkit/modules/NewTabUtils.jsm",
333       "toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js",
334       "toolkit/mozapps/extensions/test/browser/head.js",
335     ],
336     "rules": {
337       "no-async-promise-executor": "off",
338     }
339   }]