2022-03-24 18:04:53 +03:00
|
|
|
/* eslint-env node */
|
2021-07-16 17:57:07 +03:00
|
|
|
/*
|
2022-03-24 18:04:53 +03:00
|
|
|
This ESLint config aims to work with both
|
|
|
|
the JavaScript and the TypeScript parts of the
|
|
|
|
codebase.
|
2021-07-16 17:57:07 +03:00
|
|
|
*/
|
2022-03-24 18:04:53 +03:00
|
|
|
|
2021-07-16 17:57:07 +03:00
|
|
|
module.exports = {
|
2022-03-24 18:04:53 +03:00
|
|
|
root: true,
|
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
es6: true,
|
|
|
|
webextensions: true,
|
|
|
|
browser: true,
|
|
|
|
},
|
|
|
|
extends: ["prettier", "eslint:recommended"],
|
|
|
|
ignorePatterns: [
|
|
|
|
"bundled/feature.js",
|
|
|
|
"bundled/content.js",
|
|
|
|
"bundled/privileged",
|
|
|
|
"build/**",
|
|
|
|
"dist/**",
|
|
|
|
"node_modules/**",
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
"eslint-plugin-import",
|
|
|
|
"eslint-plugin-jsdoc",
|
|
|
|
"eslint-plugin-unicorn",
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
"arrow-parens": ["off", "always"],
|
|
|
|
"brace-style": ["off", "off"],
|
|
|
|
"comma-dangle": "off",
|
|
|
|
complexity: "off",
|
|
|
|
"constructor-super": "error",
|
|
|
|
"eol-last": "off",
|
|
|
|
eqeqeq: ["warn", "smart"],
|
|
|
|
"guard-for-in": "warn",
|
|
|
|
"id-blacklist": "warn",
|
|
|
|
"id-match": "warn",
|
|
|
|
"import/no-extraneous-dependencies": ["error"],
|
|
|
|
"import/no-internal-modules": "error",
|
|
|
|
"jsdoc/check-alignment": "error",
|
|
|
|
"jsdoc/check-indentation": "error",
|
|
|
|
"jsdoc/newline-after-description": "error",
|
|
|
|
"linebreak-style": "off",
|
|
|
|
"max-classes-per-file": ["error", 1],
|
|
|
|
"max-len": "off",
|
|
|
|
"new-parens": "off",
|
|
|
|
"newline-per-chained-call": "off",
|
|
|
|
"no-bitwise": "warn",
|
|
|
|
"no-caller": "error",
|
|
|
|
"no-cond-assign": "error",
|
|
|
|
"no-debugger": "error",
|
|
|
|
"no-duplicate-case": "error",
|
|
|
|
"no-duplicate-imports": "error",
|
|
|
|
"no-empty": "warn",
|
|
|
|
"no-eval": "error",
|
|
|
|
"no-extra-bind": "error",
|
|
|
|
"no-extra-semi": "off",
|
|
|
|
"no-fallthrough": "off",
|
|
|
|
"no-invalid-this": "off",
|
|
|
|
"no-irregular-whitespace": "off",
|
|
|
|
"no-multiple-empty-lines": "off",
|
|
|
|
"no-new-func": "error",
|
|
|
|
"no-new-wrappers": "error",
|
|
|
|
"no-redeclare": "error",
|
|
|
|
"no-return-await": "error",
|
|
|
|
"no-sequences": "error",
|
|
|
|
"no-sparse-arrays": "error",
|
|
|
|
"no-template-curly-in-string": "error",
|
|
|
|
"no-throw-literal": "error",
|
|
|
|
"no-trailing-spaces": "off",
|
|
|
|
"no-undef-init": "error",
|
|
|
|
"no-underscore-dangle": "warn",
|
|
|
|
"no-unsafe-finally": "error",
|
|
|
|
"no-unused-labels": "error",
|
|
|
|
"no-var": "error",
|
|
|
|
"object-shorthand": "error",
|
|
|
|
"one-var": ["warn", "never"],
|
|
|
|
"prefer-const": "error",
|
|
|
|
"prefer-object-spread": "error",
|
|
|
|
"quote-props": "off",
|
|
|
|
radix: "error",
|
|
|
|
"space-before-function-paren": "off",
|
|
|
|
"space-in-parens": ["off", "never"],
|
|
|
|
"spaced-comment": [
|
|
|
|
"error",
|
|
|
|
"always",
|
|
|
|
{
|
|
|
|
markers: ["/"],
|
|
|
|
},
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
2022-03-24 18:04:53 +03:00
|
|
|
"unicorn/prefer-ternary": "error",
|
|
|
|
"use-isnan": "error",
|
|
|
|
"valid-typeof": "off",
|
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: ["*.ts"],
|
|
|
|
parser: "@typescript-eslint/parser",
|
|
|
|
parserOptions: {
|
|
|
|
project: "tsconfig.json",
|
|
|
|
sourceType: "module",
|
|
|
|
},
|
|
|
|
plugins: ["@typescript-eslint"],
|
|
|
|
rules: {
|
2021-07-16 17:57:07 +03:00
|
|
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
|
|
"@typescript-eslint/array-type": [
|
2022-03-24 18:04:53 +03:00
|
|
|
"error",
|
|
|
|
{
|
|
|
|
default: "array",
|
|
|
|
},
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
|
|
|
"@typescript-eslint/ban-types": [
|
2022-03-24 18:04:53 +03:00
|
|
|
"error",
|
|
|
|
{
|
|
|
|
types: {
|
|
|
|
Object: {
|
|
|
|
message:
|
|
|
|
"Avoid using the `Object` type. Did you mean `object`?",
|
|
|
|
},
|
|
|
|
Function: {
|
|
|
|
message:
|
|
|
|
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
|
|
|
|
},
|
|
|
|
Boolean: {
|
|
|
|
message:
|
|
|
|
"Avoid using the `Boolean` type. Did you mean `boolean`?",
|
|
|
|
},
|
|
|
|
Number: {
|
|
|
|
message:
|
|
|
|
"Avoid using the `Number` type. Did you mean `number`?",
|
|
|
|
},
|
|
|
|
String: {
|
|
|
|
message:
|
|
|
|
"Avoid using the `String` type. Did you mean `string`?",
|
|
|
|
},
|
|
|
|
Symbol: {
|
|
|
|
message:
|
|
|
|
"Avoid using the `Symbol` type. Did you mean `symbol`?",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
|
|
|
"@typescript-eslint/consistent-type-assertions": "off",
|
|
|
|
"@typescript-eslint/dot-notation": "error",
|
|
|
|
"@typescript-eslint/indent": "off",
|
|
|
|
"@typescript-eslint/member-delimiter-style": [
|
2022-03-24 18:04:53 +03:00
|
|
|
"off",
|
|
|
|
{
|
|
|
|
multiline: {
|
|
|
|
delimiter: "none",
|
|
|
|
requireLast: true,
|
|
|
|
},
|
|
|
|
singleline: {
|
|
|
|
delimiter: "semi",
|
|
|
|
requireLast: false,
|
|
|
|
},
|
|
|
|
},
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
|
|
|
"@typescript-eslint/no-empty-function": "warn",
|
|
|
|
"@typescript-eslint/no-empty-interface": "error",
|
|
|
|
"@typescript-eslint/no-explicit-any": "off",
|
|
|
|
"@typescript-eslint/no-misused-new": "error",
|
|
|
|
"@typescript-eslint/no-namespace": "error",
|
|
|
|
"@typescript-eslint/no-parameter-properties": "off",
|
|
|
|
"@typescript-eslint/no-shadow": [
|
2022-03-24 18:04:53 +03:00
|
|
|
"off",
|
|
|
|
{
|
|
|
|
hoist: "all",
|
|
|
|
},
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
|
|
|
"@typescript-eslint/no-this-alias": "error",
|
|
|
|
"@typescript-eslint/no-unused-expressions": "warn",
|
|
|
|
"@typescript-eslint/no-use-before-define": "off",
|
|
|
|
"@typescript-eslint/no-var-requires": "error",
|
|
|
|
"@typescript-eslint/prefer-for-of": "warn",
|
|
|
|
"@typescript-eslint/prefer-function-type": "error",
|
|
|
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
|
|
"@typescript-eslint/quotes": "off",
|
2022-03-24 18:04:53 +03:00
|
|
|
"@typescript-eslint/semi": ["off", null],
|
2021-07-16 17:57:07 +03:00
|
|
|
"@typescript-eslint/triple-slash-reference": [
|
2022-03-24 18:04:53 +03:00
|
|
|
"error",
|
|
|
|
{
|
|
|
|
path: "always",
|
|
|
|
types: "prefer-import",
|
|
|
|
lib: "always",
|
|
|
|
},
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
|
|
|
"@typescript-eslint/type-annotation-spacing": "off",
|
|
|
|
"@typescript-eslint/unified-signatures": "error",
|
2022-03-24 18:04:53 +03:00
|
|
|
"no-undef": "off",
|
|
|
|
"no-unused-vars": "off",
|
|
|
|
"@typescript-eslint/no-unused-vars": [
|
|
|
|
"error",
|
|
|
|
{ argsIgnorePattern: "^_" },
|
2021-07-16 17:57:07 +03:00
|
|
|
],
|
2022-03-24 18:04:53 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-07-16 17:57:07 +03:00
|
|
|
};
|