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) {
|
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
|
|
|
];
|
|
|
|
|
2019-08-31 15:56:13 +03:00
|
|
|
const browserTestPaths = ["**/test*/**/browser/"];
|
2019-05-20 05:09:54 +03:00
|
|
|
|
2016-10-13 23:43:16 +03:00
|
|
|
module.exports = {
|
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.
|
2019-08-31 15:56:13 +03:00
|
|
|
plugins: ["html", "mozilla"],
|
2017-03-13 17:30:50 +03:00
|
|
|
|
2019-08-31 15:56:13 +03:00
|
|
|
rules: {
|
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",
|
2019-08-31 15:56:13 +03:00
|
|
|
"no-multi-spaces": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
exceptions: {
|
|
|
|
ArrayExpression: true,
|
|
|
|
AssignmentExpression: true,
|
|
|
|
ObjectExpression: true,
|
|
|
|
VariableDeclarator: true,
|
|
|
|
},
|
|
|
|
ignoreEOLComments: true,
|
2018-07-27 02:13:15 +03:00
|
|
|
},
|
2019-08-31 15:56:13 +03:00
|
|
|
],
|
|
|
|
"semi-spacing": ["error", { before: false, after: true }],
|
2018-11-29 02:04:40 +03:00
|
|
|
"space-in-parens": ["error", "never"],
|
2019-08-31 15:56:13 +03:00
|
|
|
curly: ["error", "all"],
|
2019-09-20 19:06:32 +03:00
|
|
|
|
|
|
|
// Use brace-style because Prettier covers most brace issues but not this:
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// // a comment
|
|
|
|
// else {
|
|
|
|
//
|
|
|
|
// Allow single line for inline JS in XUL files.
|
|
|
|
"brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
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: [
|
|
|
|
{
|
|
|
|
// 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
|
|
|
},
|
2019-08-31 15:56:13 +03:00
|
|
|
{
|
|
|
|
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,
|
|
|
|
files: browserTestPaths.map(path => `${path}**`),
|
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
|
|
|
};
|