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 // 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.
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"
72 "mozilla/browser-window": true
75 // TODO: Bug 1515949. Enable no-undef for gfx/
76 "files": "gfx/layers/apz/test/mochitest/**",
81 ...removeOverrides(xpcshellTestConfig),
82 "files": xpcshellTestPaths.map(path => `${path}**`),
83 "excludedFiles": "devtools/**"
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 "no-unused-vars": ["error", {
98 "files": browserTestPaths.map(path => `${path}**`),
99 "excludedFiles": "devtools/**"
101 ...removeOverrides(mochitestTestConfig),
102 "files": mochitestTestPaths.map(path => `${path}**`),
105 "security/manager/ssl/tests/mochitest/browser/**",
106 "testing/mochitest/**",
109 ...removeOverrides(chromeTestConfig),
110 "files": chromeTestPaths.map(path => `${path}**`),
116 // Ideally we wouldn't be using the simpletest env here, but our uses of
117 // js files mean we pick up everything from the global scope, which could
118 // be any one of a number of html files. So we just allow the basics...
119 "mozilla/simpletest": true,
122 ...mochitestTestPaths.map(path => `${path}/**/*.js`),
123 ...chromeTestPaths.map(path => `${path}/**/*.js`),
127 "extensions/permissions/test/**",
128 "extensions/spellcheck/**",
129 "extensions/universalchardet/tests/**",
132 "mozilla/reject-importGlobalProperties": "off",
133 "mozilla/use-default-preference-values": "off",
134 "mozilla/use-services": "off",
135 "no-array-constructor": "off",
137 "no-unused-vars": "off",
138 "no-redeclare": "off",
139 "no-global-assign": "off",
146 "mozilla/consistent-if-bracing": "off",
147 "mozilla/use-chromeutils-generateqi": "off",
148 "mozilla/use-services": "off",
149 "no-array-constructor": "off",
150 "no-implied-eval": "off",
151 "no-redeclare": "off",
152 "no-self-assign": "off",
153 "no-throw-literal": "off",
155 "no-unneeded-ternary": "off",
156 "no-unused-vars": "off",
160 "netwerk/cookie/test/browser/**",
161 "netwerk/test/browser/**",
162 "netwerk/test/mochitests/**",
163 "netwerk/test/unit*/**",
166 "mozilla/consistent-if-bracing": "off",
167 "mozilla/reject-importGlobalProperties": "off",
168 "mozilla/no-arbitrary-setTimeout": "off",
169 "mozilla/no-define-cc-etc": "off",
170 "mozilla/use-default-preference-values": "off",
171 "mozilla/use-services": "off",
172 "consistent-return": "off",
173 "no-array-constructor": "off",
175 "no-global-assign": "off",
176 "no-nested-ternary": "off",
177 "no-new-wrappers": "off",
178 "no-redeclare": "off",
179 "no-return-await": "off",
180 "no-sequences": "off",
182 "no-throw-literal": "off",
184 "no-unreachable": "off",
185 "no-unused-vars": "off",
186 "no-useless-return": "off",
193 "object-shorthand": "off",
194 "mozilla/avoid-removeChild": "off",
195 "mozilla/consistent-if-bracing": "off",
196 "mozilla/reject-importGlobalProperties": "off",
197 "mozilla/no-arbitrary-setTimeout": "off",
198 "mozilla/no-define-cc-etc": "off",
199 "mozilla/use-chromeutils-generateqi": "off",
200 "mozilla/use-default-preference-values": "off",
201 "mozilla/use-includes-instead-of-indexOf": "off",
202 "mozilla/use-services": "off",
203 "mozilla/use-ownerGlobal": "off",
205 "consistent-return": "off",
206 "no-array-constructor": "off",
208 "no-cond-assign": "off",
209 "no-extra-boolean-cast": "off",
211 "no-func-assign": "off",
212 "no-global-assign": "off",
213 "no-implied-eval": "off",
214 "no-lonely-if": "off",
215 "no-nested-ternary": "off",
216 "no-new-wrappers": "off",
217 "no-redeclare": "off",
218 "no-restricted-globals": "off",
219 "no-return-await": "off",
220 "no-sequences": "off",
221 "no-throw-literal": "off",
222 "no-useless-concat": "off",
224 "no-unreachable": "off",
225 "no-unsanitized/method": "off",
226 "no-unsanitized/property": "off",
227 "no-unsafe-negation": "off",
228 "no-unused-vars": "off",
229 "no-useless-return": "off",
235 "dom/base/test/unit/test_serializers_entities*.js",
236 "dom/base/test/unit_ipc/**",
237 "dom/base/test/jsmodules/**",
246 "dom/media/tests/**",
247 "dom/media/webaudio/**",
248 "dom/media/webspeech/**",
249 "dom/messagechannel/**",
253 "dom/performance/**",
256 "dom/security/test/cors/**",
257 "dom/security/test/csp/**",
258 "dom/security/test/general/**",
259 "dom/security/test/mixedcontentblocker/**",
260 "dom/security/test/sri/**",
261 "dom/serviceworkers/**",
263 "dom/tests/mochitest/**",
277 "consistent-return": "off",
278 "dot-notation": "off",
279 "object-shorthand": "off",
280 "mozilla/avoid-removeChild": "off",
281 "mozilla/consistent-if-bracing": "off",
282 "mozilla/no-arbitrary-setTimeout": "off",
283 "mozilla/no-compare-against-boolean-literals": "off",
284 "mozilla/no-define-cc-etc": "off",
285 "mozilla/no-useless-parameters": "off",
286 "mozilla/no-useless-run-test": "off",
287 "mozilla/reject-importGlobalProperties": "off",
288 "mozilla/use-cc-etc": "off",
289 "mozilla/use-chromeutils-generateqi": "off",
290 "mozilla/use-chromeutils-import": "off",
291 "mozilla/use-includes-instead-of-indexOf": "off",
292 "mozilla/use-ownerGlobal": "off",
293 "mozilla/use-services": "off",
294 "no-array-constructor": "off",
296 "no-cond-assign": "off",
297 "no-control-regex": "off",
298 "no-debugger": "off",
299 "no-else-return": "off",
302 "no-extra-boolean-cast": "off",
303 "no-func-assign": "off",
304 "no-global-assign": "off",
305 "no-implied-eval": "off",
306 "no-lone-blocks": "off",
307 "no-lonely-if": "off",
308 "no-nested-ternary": "off",
309 "no-new-object": "off",
310 "no-new-wrappers": "off",
312 "no-redeclare": "off",
313 "no-return-await": "off",
314 "no-restricted-globals": "off",
315 "no-self-assign": "off",
316 "no-self-compare": "off",
317 "no-sequences": "off",
319 "no-shadow-restricted-names": "off",
320 "no-sparse-arrays": "off",
321 "no-throw-literal": "off",
322 "no-unneeded-ternary": "off",
323 "no-unreachable": "off",
324 "no-unsanitized/method": "off",
325 "no-unsanitized/property": "off",
327 "no-unused-vars": "off",
328 "no-useless-call": "off",
329 "no-useless-concat": "off",
330 "no-useless-return": "off",