2016-10-13 23:43:16 +03:00
|
|
|
"use strict";
|
|
|
|
|
2021-04-05 12:41:39 +03:00
|
|
|
const path = require("path");
|
|
|
|
|
2019-05-20 05:09:54 +03:00
|
|
|
const xpcshellTestConfig = require("eslint-plugin-mozilla/lib/configs/xpcshell-test.js");
|
|
|
|
const browserTestConfig = require("eslint-plugin-mozilla/lib/configs/browser-test.js");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some configurations have overrides, which can't be specified within overrides,
|
|
|
|
* so we need to remove them.
|
|
|
|
*/
|
|
|
|
function removeOverrides(config) {
|
2019-08-31 15:56:13 +03:00
|
|
|
config = { ...config };
|
2019-05-20 05:09:54 +03:00
|
|
|
delete config.overrides;
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
const xpcshellTestPaths = [
|
|
|
|
"**/test*/unit*/",
|
|
|
|
"**/test*/xpcshell/",
|
2019-05-20 20:29:08 +03:00
|
|
|
"chat/**/test*/",
|
2019-05-20 05:09:54 +03:00
|
|
|
];
|
|
|
|
|
2020-08-26 13:22:36 +03:00
|
|
|
const browserTestPaths = [
|
|
|
|
"**/test*/**/browser/",
|
|
|
|
"mail/base/test/performance/",
|
2021-07-21 07:43:35 +03:00
|
|
|
"mail/base/test/webextensions/",
|
|
|
|
"mail/test/static/",
|
2020-08-26 13:22:36 +03:00
|
|
|
];
|
2019-05-20 05:09:54 +03:00
|
|
|
|
2016-10-13 23:43:16 +03:00
|
|
|
module.exports = {
|
2021-04-05 12:41:39 +03:00
|
|
|
parser: "@babel/eslint-parser",
|
2020-05-21 11:15:08 +03:00
|
|
|
parserOptions: {
|
|
|
|
sourceType: "script",
|
|
|
|
babelOptions: {
|
2021-04-05 12:41:39 +03:00
|
|
|
configFile: path.join(__dirname, "..", ".babel-eslint.rc.js"),
|
2020-05-21 11:15:08 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-08-31 15:56:13 +03:00
|
|
|
root: true,
|
2017-03-13 17:30:50 +03:00
|
|
|
|
|
|
|
// We would like the same base rules as provided by
|
|
|
|
// mozilla/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
|
2019-08-31 15:56:13 +03:00
|
|
|
extends: ["plugin:mozilla/recommended"],
|
2017-03-13 17:30:50 +03:00
|
|
|
|
2016-06-20 15:22:18 +03:00
|
|
|
// When adding items to this file please check for effects on sub-directories.
|
2020-05-21 11:15:08 +03:00
|
|
|
plugins: ["mozilla"],
|
2017-03-13 17:30:50 +03:00
|
|
|
|
2019-08-31 15:56:13 +03:00
|
|
|
rules: {
|
2020-02-20 01:24:47 +03:00
|
|
|
complexity: ["error", 80],
|
2018-11-29 02:04:40 +03:00
|
|
|
"func-names": ["error", "never"],
|
2019-10-17 11:45:54 +03:00
|
|
|
"mozilla/prefer-boolean-length-check": "off",
|
2018-02-08 12:43:53 +03:00
|
|
|
},
|
|
|
|
|
2019-06-24 03:40:02 +03:00
|
|
|
// To avoid bad interactions of the html plugin with the xml preprocessor in
|
|
|
|
// eslint-plugin-mozilla, we turn off processing of the html plugin for .xml
|
|
|
|
// files.
|
2019-08-31 15:56:13 +03:00
|
|
|
settings: {
|
|
|
|
"html/xml-extensions": [".xhtml"],
|
2016-06-20 15:22:18 +03:00
|
|
|
},
|
2017-11-15 17:24:49 +03:00
|
|
|
|
2019-08-31 15:56:13 +03:00
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: "**/.eslintrc.js",
|
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
2018-11-02 11:04:58 +03:00
|
|
|
},
|
2019-08-31 15:56:13 +03:00
|
|
|
{
|
|
|
|
...removeOverrides(xpcshellTestConfig),
|
|
|
|
files: xpcshellTestPaths.map(path => `${path}**`),
|
|
|
|
rules: {
|
2019-10-24 12:12:17 +03:00
|
|
|
...xpcshellTestConfig.rules,
|
2019-08-31 15:56:13 +03:00
|
|
|
"func-names": "off",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-11-05 06:48:02 +03:00
|
|
|
// If it is a test head file, we turn off global unused variable checks, as it
|
2019-08-31 15:56:13 +03:00
|
|
|
// 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.
|
2019-11-05 06:48:02 +03:00
|
|
|
files: [
|
|
|
|
...browserTestPaths.map(path => `${path}head*.js`),
|
|
|
|
...xpcshellTestPaths.map(path => `${path}head*.js`),
|
|
|
|
],
|
2019-08-31 15:56:13 +03:00
|
|
|
rules: {
|
|
|
|
"no-unused-vars": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
args: "none",
|
|
|
|
vars: "local",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-05-20 05:09:54 +03:00
|
|
|
},
|
2019-08-31 15:56:13 +03:00
|
|
|
{
|
|
|
|
...browserTestConfig,
|
2021-09-09 05:27:19 +03:00
|
|
|
files: browserTestPaths.map(path => `${path}**/*.js`),
|
2019-09-27 07:00:10 +03:00
|
|
|
rules: {
|
2019-10-24 12:12:17 +03:00
|
|
|
...browserTestConfig.rules,
|
2019-09-27 07:00:10 +03:00
|
|
|
"func-names": "off",
|
|
|
|
},
|
2019-05-20 05:09:54 +03:00
|
|
|
},
|
2019-08-31 15:56:13 +03:00
|
|
|
],
|
2016-10-13 23:43:16 +03:00
|
|
|
};
|