Bug 1468402 - Part 3: Add test for subgrids in the grid list. r=pbro
[gecko.git] / .eslintrc.js
blobd8099a4349ce7f94e5af6d9f2a5e0b561f11c3eb
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 1513639. Temporarily turn off reject-importGlobalProperties
76     // due to other ESLint enabling happening in DOM.
77     "files": "dom/**",
78     "rules": {
79       "mozilla/reject-importGlobalProperties": "off",
80     }
81   }, {
82     // TODO: Bug 1515949. Enable no-undef for gfx/
83     "files": "gfx/layers/apz/test/mochitest/**",
84     "rules": {
85       "no-undef": "off",
86     }
87   }, {
88     ...removeOverrides(xpcshellTestConfig),
89     "files": xpcshellTestPaths.map(path => `${path}**`),
90     "excludedFiles": "devtools/**"
91   }, {
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`),
98     "rules": {
99       "no-unused-vars": ["error", {
100         "args": "none",
101         "vars": "local",
102       }],
103     },
104   }, {
105     ...browserTestConfig,
106     "files": browserTestPaths.map(path => `${path}**`),
107     "excludedFiles": "devtools/**"
108   }, {
109     ...removeOverrides(mochitestTestConfig),
110     "files": mochitestTestPaths.map(path => `${path}**`),
111     "excludedFiles": [
112       "devtools/**",
113       "security/manager/ssl/tests/mochitest/browser/**",
114       "testing/mochitest/**",
115     ],
116   }, {
117     ...removeOverrides(chromeTestConfig),
118     "files": chromeTestPaths.map(path => `${path}**`),
119     "excludedFiles": [
120       "devtools/**",
121     ],
122   }, {
123     "env": {
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,
128     },
129     "files": [
130       ...mochitestTestPaths.map(path => `${path}/**/*.js`),
131       ...chromeTestPaths.map(path => `${path}/**/*.js`),
132     ],
133   }]