2016-10-18 10:38:10 +03:00
|
|
|
"use strict";
|
|
|
|
|
2019-03-28 12:38:02 +03:00
|
|
|
const xpcshellTestConfig = require("eslint-plugin-mozilla/lib/configs/xpcshell-test.js");
|
|
|
|
const browserTestConfig = require("eslint-plugin-mozilla/lib/configs/browser-test.js");
|
|
|
|
const mochitestTestConfig = require("eslint-plugin-mozilla/lib/configs/mochitest-test.js");
|
|
|
|
const chromeTestConfig = require("eslint-plugin-mozilla/lib/configs/chrome-test.js");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some configurations have overrides, which can't be specified within overrides,
|
|
|
|
* so we need to remove them.
|
|
|
|
*/
|
|
|
|
function removeOverrides(config) {
|
|
|
|
config = {...config};
|
|
|
|
delete config.overrides;
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
const xpcshellTestPaths = [
|
|
|
|
"**/test*/unit*/",
|
|
|
|
"**/test*/xpcshell/",
|
|
|
|
];
|
|
|
|
|
|
|
|
const browserTestPaths = [
|
|
|
|
"**/test*/**/browser/",
|
|
|
|
];
|
|
|
|
|
|
|
|
const mochitestTestPaths = [
|
|
|
|
"**/test*/mochitest/",
|
|
|
|
];
|
|
|
|
|
|
|
|
const chromeTestPaths = [
|
|
|
|
"**/test*/chrome/",
|
|
|
|
];
|
|
|
|
|
2016-10-18 10:38:10 +03:00
|
|
|
module.exports = {
|
2017-04-25 22:12:21 +03:00
|
|
|
// New rules and configurations should generally be added in
|
|
|
|
// tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js to
|
|
|
|
// allow external repositories that use the plugin to pick them up as well.
|
|
|
|
"extends": [
|
|
|
|
"plugin:mozilla/recommended"
|
|
|
|
],
|
2015-09-30 16:44:48 +03:00
|
|
|
"plugins": [
|
|
|
|
"mozilla"
|
2015-11-30 14:42:25 +03:00
|
|
|
],
|
2017-05-08 12:29:47 +03:00
|
|
|
// The html plugin is enabled via a command line option on eslint. To avoid
|
|
|
|
// bad interactions with the xml preprocessor in eslint-plugin-mozilla, we
|
|
|
|
// turn off processing of the html plugin for .xml files.
|
|
|
|
"settings": {
|
|
|
|
"html/xml-extensions": [ ".xhtml" ]
|
|
|
|
},
|
2017-10-09 12:54:16 +03:00
|
|
|
|
|
|
|
"overrides": [{
|
|
|
|
// eslint-plugin-html handles eol-last slightly different - it applies to
|
|
|
|
// each set of script tags, so we turn it off here.
|
|
|
|
"files": "**/*.*html",
|
|
|
|
"rules": {
|
|
|
|
"eol-last": "off",
|
|
|
|
}
|
2017-11-28 22:24:12 +03:00
|
|
|
}, {
|
2018-02-07 19:02:25 +03:00
|
|
|
// These xbl bindings are assumed to be in the browser-window environment,
|
|
|
|
// we would mark it in the files, but ESLint made this more difficult with
|
|
|
|
// our xml processor, so we list them here. Bug 1397874 & co are working
|
|
|
|
// towards removing these files completely.
|
|
|
|
"files": [
|
|
|
|
"browser/base/content/tabbrowser.xml",
|
|
|
|
"browser/base/content/urlbarBindings.xml",
|
|
|
|
"browser/components/search/content/search.xml",
|
|
|
|
"browser/components/translation/translation-infobar.xml",
|
|
|
|
"toolkit/components/prompts/content/tabprompts.xml"
|
|
|
|
],
|
|
|
|
"env": {
|
|
|
|
"mozilla/browser-window": true
|
|
|
|
}
|
2018-12-12 22:04:35 +03:00
|
|
|
}, {
|
|
|
|
// TODO: Bug 1513639. Temporarily turn off reject-importGlobalProperties
|
|
|
|
// due to other ESLint enabling happening in DOM.
|
|
|
|
"files": "dom/**",
|
|
|
|
"rules": {
|
|
|
|
"mozilla/reject-importGlobalProperties": "off",
|
|
|
|
}
|
2018-12-27 12:45:01 +03:00
|
|
|
}, {
|
|
|
|
// TODO: Bug 1515949. Enable no-undef for gfx/
|
|
|
|
"files": "gfx/layers/apz/test/mochitest/**",
|
|
|
|
"rules": {
|
|
|
|
"no-undef": "off",
|
|
|
|
}
|
2019-03-28 12:38:02 +03:00
|
|
|
}, {
|
|
|
|
...removeOverrides(xpcshellTestConfig),
|
|
|
|
"files": xpcshellTestPaths.map(path => `${path}**`),
|
|
|
|
"excludedFiles": "devtools/**"
|
|
|
|
}, {
|
|
|
|
// If it is an xpcshell head file, we turn off global unused variable checks, as it
|
|
|
|
// would require searching the other test files to know if they are used or not.
|
|
|
|
// This would be expensive and slow, and it isn't worth it for head files.
|
|
|
|
// We could get developers to declare as exported, but that doesn't seem worth it.
|
|
|
|
"files": xpcshellTestPaths.map(path => `${path}head*.js`),
|
|
|
|
|
|
|
|
"rules": {
|
|
|
|
"no-unused-vars": ["error", {
|
|
|
|
"args": "none",
|
|
|
|
"vars": "local",
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
...browserTestConfig,
|
|
|
|
"files": browserTestPaths.map(path => `${path}**`),
|
|
|
|
"excludedFiles": "devtools/**"
|
|
|
|
}, {
|
|
|
|
...removeOverrides(mochitestTestConfig),
|
|
|
|
"files": mochitestTestPaths.map(path => `${path}**`),
|
|
|
|
"excludedFiles": [
|
|
|
|
"devtools/**",
|
|
|
|
"security/manager/ssl/tests/mochitest/browser/**",
|
|
|
|
"testing/mochitest/**",
|
|
|
|
],
|
|
|
|
}, {
|
|
|
|
...removeOverrides(chromeTestConfig),
|
|
|
|
"files": chromeTestPaths.map(path => `${path}**`),
|
|
|
|
"excludedFiles": [
|
|
|
|
"devtools/**",
|
|
|
|
],
|
|
|
|
}, {
|
|
|
|
"env": {
|
|
|
|
// Ideally we wouldn't be using the simpletest env here, but our uses of
|
|
|
|
// js files mean we pick up everything from the global scope, which could
|
|
|
|
// be any one of a number of html files. So we just allow the basics...
|
|
|
|
"mozilla/simpletest": true,
|
|
|
|
},
|
|
|
|
"files": [
|
|
|
|
...mochitestTestPaths.map(path => `${path}/**/*.js`),
|
|
|
|
...chromeTestPaths.map(path => `${path}/**/*.js`),
|
|
|
|
],
|
2017-10-09 12:54:16 +03:00
|
|
|
}]
|
2016-10-18 10:38:10 +03:00
|
|
|
};
|