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"
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.
49 "html/xml-extensions": [ ".xhtml" ]
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",
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 1513639. Temporarily turn off reject-importGlobalProperties
76 // due to other ESLint enabling happening in DOM.
79 "mozilla/reject-importGlobalProperties": "off",
82 // TODO: Bug 1515949. Enable no-undef for gfx/
83 "files": "gfx/layers/apz/test/mochitest/**",
88 ...removeOverrides(xpcshellTestConfig),
89 "files": xpcshellTestPaths.map(path => `${path}**`),
90 "excludedFiles": "devtools/**"
92 // If it is an xpcshell head file, we turn off global unused variable checks, as it
93 // would require searching the other test files to know if they are used or not.
94 // This would be expensive and slow, and it isn't worth it for head files.
95 // We could get developers to declare as exported, but that doesn't seem worth it.
96 "files": xpcshellTestPaths.map(path => `${path}head*.js`),
99 "no-unused-vars": ["error", {
105 ...browserTestConfig,
106 "files": browserTestPaths.map(path => `${path}**`),
107 "excludedFiles": "devtools/**"
109 ...removeOverrides(mochitestTestConfig),
110 "files": mochitestTestPaths.map(path => `${path}**`),
113 "security/manager/ssl/tests/mochitest/browser/**",
114 "testing/mochitest/**",
117 ...removeOverrides(chromeTestConfig),
118 "files": chromeTestPaths.map(path => `${path}**`),
124 // Ideally we wouldn't be using the simpletest env here, but our uses of
125 // js files mean we pick up everything from the global scope, which could
126 // be any one of a number of html files. So we just allow the basics...
127 "mozilla/simpletest": true,
130 ...mochitestTestPaths.map(path => `${path}/**/*.js`),
131 ...chromeTestPaths.map(path => `${path}/**/*.js`),