2016-10-13 23:43:16 +03:00
|
|
|
"use strict";
|
|
|
|
|
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) {
|
|
|
|
config = {...config};
|
|
|
|
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
|
|
|
];
|
|
|
|
|
|
|
|
const browserTestPaths = [
|
|
|
|
"**/test*/**/browser/",
|
|
|
|
];
|
|
|
|
|
2016-10-13 23:43:16 +03:00
|
|
|
module.exports = {
|
2017-03-13 17:30:50 +03:00
|
|
|
"root": true,
|
|
|
|
|
|
|
|
// We would like the same base rules as provided by
|
|
|
|
// mozilla/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
|
|
|
|
"extends": [
|
2018-09-01 01:53:28 +03:00
|
|
|
"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.
|
|
|
|
"plugins": [
|
2018-09-01 01:53:28 +03:00
|
|
|
"mozilla",
|
2016-06-20 15:22:18 +03:00
|
|
|
],
|
2017-03-13 17:30:50 +03:00
|
|
|
|
2018-02-08 12:43:53 +03:00
|
|
|
"rules": {
|
2018-11-29 02:04:40 +03:00
|
|
|
"func-names": ["error", "never"],
|
2018-07-27 02:13:15 +03:00
|
|
|
"no-multi-spaces": ["error", {
|
|
|
|
exceptions: {
|
|
|
|
"ArrayExpression": true,
|
|
|
|
"AssignmentExpression": true,
|
|
|
|
"ObjectExpression": true,
|
2018-09-01 01:53:28 +03:00
|
|
|
"VariableDeclarator": true,
|
2018-07-27 02:13:15 +03:00
|
|
|
},
|
2018-09-01 01:53:28 +03:00
|
|
|
ignoreEOLComments: true,
|
|
|
|
}],
|
2018-11-29 02:04:40 +03:00
|
|
|
"semi-spacing": ["error", {"before": false, "after": true}],
|
|
|
|
"space-in-parens": ["error", "never"],
|
2018-02-08 12:43:53 +03:00
|
|
|
},
|
|
|
|
|
2017-03-13 17:30:50 +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": {
|
2018-09-01 01:53:28 +03:00
|
|
|
"html/xml-extensions": [ ".xhtml" ],
|
2016-06-20 15:22:18 +03:00
|
|
|
},
|
2017-11-15 17:24:49 +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",
|
2018-09-01 01:53:28 +03:00
|
|
|
},
|
2018-11-02 11:04:58 +03:00
|
|
|
}, {
|
|
|
|
"files": "**/.eslintrc.js",
|
|
|
|
"env": {
|
|
|
|
"node": true,
|
|
|
|
},
|
2019-05-20 05:09:54 +03:00
|
|
|
}, {
|
|
|
|
...removeOverrides(xpcshellTestConfig),
|
|
|
|
"files": xpcshellTestPaths.map(path => `${path}**`),
|
|
|
|
"rules": {
|
|
|
|
"func-names": "off",
|
|
|
|
"mozilla/import-headjs-globals": "error",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
// 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}**`),
|
2018-09-01 01:53:28 +03:00
|
|
|
}],
|
2016-10-13 23:43:16 +03:00
|
|
|
};
|