|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + parser: "@typescript-eslint/parser", |
| 4 | + plugins: ["@typescript-eslint", "prettier"], |
| 5 | + env: { |
| 6 | + node: true, |
| 7 | + es6: true, |
| 8 | + }, |
| 9 | + extends: [ |
| 10 | + "airbnb", |
| 11 | + "eslint:recommended", |
| 12 | + "plugin:@typescript-eslint/recommended", |
| 13 | + "plugin:eslint-comments/recommended", |
| 14 | + // Disable below extends and parser options if having performance issues |
| 15 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md |
| 16 | + "plugin:@typescript-eslint/recommended-requiring-type-checking", |
| 17 | + ], |
| 18 | + rules: { |
| 19 | + // --------------------------------------------------------- |
| 20 | + // --- Rules from eslint:recommended that we override |
| 21 | + // --------------------------------------------------------- |
| 22 | + "class-methods-use-this": ["error", { "exceptMethods": ["errorEvent", "connectedEvent"] }], |
| 23 | + "no-unused-vars": "off", // because it flags types that are imported for type declarations (but otherwise unused). |
| 24 | + "no-undef": "off", // because if flags lack of import for Set. // TODO: fix the issues and remove this override. |
| 25 | + |
| 26 | + // --------------------------------------------------------- |
| 27 | + // --- Rules that we add and/or customize |
| 28 | + // --------------------------------------------------------- |
| 29 | + |
| 30 | + eqeqeq: ["error", "smart"], |
| 31 | + "guard-for-in": "error", |
| 32 | + "id-blacklist": [ |
| 33 | + "error", |
| 34 | + "any", |
| 35 | + "Number", |
| 36 | + "number", |
| 37 | + "String", |
| 38 | + "string", |
| 39 | + "Boolean", |
| 40 | + "boolean", |
| 41 | + "Undefined", |
| 42 | + "undefined", |
| 43 | + ], |
| 44 | + "id-match": "error", |
| 45 | + "import/extensions": [ |
| 46 | + "error", |
| 47 | + "ignorePackages", |
| 48 | + { |
| 49 | + "js": "never", |
| 50 | + "jsx": "never", |
| 51 | + "ts": "never", |
| 52 | + "tsx": "never" |
| 53 | + } |
| 54 | + ], |
| 55 | + "import/no-cycle": "off", |
| 56 | + "import/no-default-export": "error", |
| 57 | + "import/no-extraneous-dependencies": ["off", { devDependencies: false }], |
| 58 | + "import/prefer-default-export": "off", |
| 59 | + indent: "off", |
| 60 | + "jsx-a11y/control-has-associated-label": "off", |
| 61 | + "jsx-a11y/label-has-associated-control": "off", |
| 62 | + "new-parens": "error", |
| 63 | + "no-caller": "error", |
| 64 | + "no-duplicate-imports": "error", |
| 65 | + "no-eval": "error", |
| 66 | + "no-extra-bind": "error", |
| 67 | + "no-new-func": "error", |
| 68 | + "no-new-wrappers": "error", |
| 69 | + "no-return-await": "error", |
| 70 | + "no-sequences": "error", |
| 71 | + "no-shadow": ["off", { hoist: "all" }], |
| 72 | + "no-undef-init": "error", |
| 73 | + "no-underscore-dangle": ["error", { |
| 74 | + "allowAfterThis": true |
| 75 | + }], |
| 76 | + "no-var": "error", |
| 77 | + "object-shorthand": "error", |
| 78 | + "one-var": ["error", "never"], |
| 79 | + "prefer-const": "error", |
| 80 | + "prefer-object-spread": "error", |
| 81 | + radix: "error", |
| 82 | + |
| 83 | + "@typescript-eslint/strict-boolean-expressions": ["error"], // avoids frequent sources of errors: 0, "", Promise<T>, null vs undefined |
| 84 | + "@typescript-eslint/adjacent-overload-signatures": "error", |
| 85 | + "@typescript-eslint/array-type": ["error", { default: "array-simple" }], |
| 86 | + "@typescript-eslint/ban-types": [ |
| 87 | + "error", |
| 88 | + { |
| 89 | + types: { |
| 90 | + Object: { |
| 91 | + message: "Avoid using the `Object` type. Did you mean `object`?", |
| 92 | + }, |
| 93 | + Function: { |
| 94 | + message: |
| 95 | + "Avoid using the `Function` type. Prefer a specific function type, like `() => void`.", |
| 96 | + }, |
| 97 | + Boolean: { |
| 98 | + message: "Avoid using the `Boolean` type. Did you mean `boolean`?", |
| 99 | + }, |
| 100 | + Number: { |
| 101 | + message: "Avoid using the `Number` type. Did you mean `number`?", |
| 102 | + }, |
| 103 | + String: { |
| 104 | + message: "Avoid using the `String` type. Did you mean `string`?", |
| 105 | + }, |
| 106 | + Symbol: { |
| 107 | + message: "Avoid using the `Symbol` type. Did you mean `symbol`?", |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | + ], |
| 112 | + "@typescript-eslint/consistent-type-assertions": "error", |
| 113 | + "@typescript-eslint/consistent-type-definitions": "off", |
| 114 | + "@typescript-eslint/explicit-member-accessibility": [ |
| 115 | + "off", |
| 116 | + { accessibility: "explicit" }, |
| 117 | + ], |
| 118 | + "@typescript-eslint/interface-name-prefix": "off", |
| 119 | + "@typescript-eslint/member-ordering": "off", |
| 120 | + "@typescript-eslint/no-empty-function": "off", |
| 121 | + "@typescript-eslint/no-empty-interface": "off", |
| 122 | + "@typescript-eslint/no-explicit-any": "off", |
| 123 | + "@typescript-eslint/no-misused-new": "error", |
| 124 | + "@typescript-eslint/no-floating-promises": ["error"], // prevent those nasty forgotten promises ! |
| 125 | + "@typescript-eslint/no-namespace": "off", |
| 126 | + "@typescript-eslint/no-parameter-properties": "off", |
| 127 | + "@typescript-eslint/no-this-alias": "error", |
| 128 | + "@typescript-eslint/no-unused-expressions": "off", |
| 129 | + "@typescript-eslint/no-use-before-define": "off", |
| 130 | + "@typescript-eslint/no-var-requires": "error", |
| 131 | + "@typescript-eslint/prefer-for-of": "error", |
| 132 | + "@typescript-eslint/prefer-function-type": "error", |
| 133 | + "@typescript-eslint/prefer-namespace-keyword": "error", |
| 134 | + "@typescript-eslint/triple-slash-reference": [ |
| 135 | + "error", |
| 136 | + { |
| 137 | + path: "always", |
| 138 | + types: "prefer-import", |
| 139 | + lib: "always", |
| 140 | + }, |
| 141 | + ], |
| 142 | + "@typescript-eslint/type-annotation-spacing": "error", |
| 143 | + "@typescript-eslint/unified-signatures": "error", |
| 144 | + |
| 145 | + // -- Rules form tsdoc |
| 146 | + // "tsdoc/syntax": "warn", // TODO: enable once we have better tsdoc coverage |
| 147 | + }, |
| 148 | + parserOptions: { |
| 149 | + ecmaVersion: 6, |
| 150 | + sourceType: "module", |
| 151 | + // Disable below extends and parser options if having performance issues |
| 152 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md |
| 153 | + tsconfigRootDir: __dirname, |
| 154 | + project: "./tsconfig.json", |
| 155 | + }, |
| 156 | + settings: { |
| 157 | + "import/extensions": [".js", ".jsx", ".ts", ".tsx"], |
| 158 | + "import/parsers": { |
| 159 | + "@typescript-eslint/parser": [".ts", ".tsx"], |
| 160 | + }, |
| 161 | + "import/resolver": { |
| 162 | + node: { |
| 163 | + extensions: [".js", ".jsx", ".ts", ".tsx"], |
| 164 | + }, |
| 165 | + // use <root>/tsconfig.json |
| 166 | + typescript: { |
| 167 | + // "alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`, |
| 168 | + // "directory": "./" |
| 169 | + }, |
| 170 | + }, |
| 171 | + }, |
| 172 | +}; |
0 commit comments