|
| 1 | +module.exports = { |
| 2 | + env: { |
| 3 | + browser: true, |
| 4 | + es6: true, |
| 5 | + node: true, |
| 6 | + }, |
| 7 | + |
| 8 | + parser: '@typescript-eslint/parser', |
| 9 | + parserOptions: { |
| 10 | + project: ['./packages/*/tsconfig.json'], |
| 11 | + sourceType: 'module', |
| 12 | + }, |
| 13 | + ignorePatterns: [ |
| 14 | + '.eslintrc.js', |
| 15 | + '**/*.js', |
| 16 | + '**/node_modules/**', |
| 17 | + '**/dist/**', |
| 18 | + '**/test/**', |
| 19 | + '**/templates/**', |
| 20 | + '**/ormconfig.ts', |
| 21 | + '**/migrations/**', |
| 22 | + ], |
| 23 | + |
| 24 | + extends: [ |
| 25 | + /** |
| 26 | + * Config for typescript-eslint recommended ruleset (without type checking) |
| 27 | + * |
| 28 | + * https://github.com/typescript-eslint/typescript-eslint/blob/1c1b572c3000d72cfe665b7afbada0ec415e7855/packages/eslint-plugin/src/configs/recommended.ts |
| 29 | + */ |
| 30 | + 'plugin:@typescript-eslint/recommended', |
| 31 | + |
| 32 | + /** |
| 33 | + * Config for typescript-eslint recommended ruleset (with type checking) |
| 34 | + * |
| 35 | + * https://github.com/typescript-eslint/typescript-eslint/blob/1c1b572c3000d72cfe665b7afbada0ec415e7855/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts |
| 36 | + */ |
| 37 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 38 | + |
| 39 | + /** |
| 40 | + * Config for Airbnb style guide for TS, /base to remove React rules |
| 41 | + * |
| 42 | + * https://github.com/iamturns/eslint-config-airbnb-typescript |
| 43 | + * https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base/rules |
| 44 | + */ |
| 45 | + 'eslint-config-airbnb-typescript/base', |
| 46 | + |
| 47 | + /** |
| 48 | + * Config to disable ESLint rules covered by Prettier |
| 49 | + * |
| 50 | + * https://github.com/prettier/eslint-config-prettier |
| 51 | + */ |
| 52 | + 'eslint-config-prettier', |
| 53 | + ], |
| 54 | + |
| 55 | + plugins: [ |
| 56 | + /** |
| 57 | + * Plugin with lint rules for import/export syntax |
| 58 | + * https://github.com/import-js/eslint-plugin-import |
| 59 | + */ |
| 60 | + 'eslint-plugin-import', |
| 61 | + |
| 62 | + /** |
| 63 | + * @typescript-eslint/eslint-plugin is required by eslint-config-airbnb-typescript |
| 64 | + * See step 2: https://github.com/iamturns/eslint-config-airbnb-typescript#2-install-eslint-plugins |
| 65 | + */ |
| 66 | + '@typescript-eslint', |
| 67 | + |
| 68 | + /** |
| 69 | + * Plugin to report formatting violations as lint violations |
| 70 | + * https://github.com/prettier/eslint-plugin-prettier |
| 71 | + */ |
| 72 | + 'eslint-plugin-prettier', |
| 73 | + ], |
| 74 | + |
| 75 | + rules: { |
| 76 | + // ****************************************************************** |
| 77 | + // required by prettier plugin |
| 78 | + // ****************************************************************** |
| 79 | + |
| 80 | + // The following rule enables eslint-plugin-prettier |
| 81 | + // See: https://github.com/prettier/eslint-plugin-prettier#recommended-configuration |
| 82 | + |
| 83 | + 'prettier/prettier': 'error', |
| 84 | + |
| 85 | + // The following two rules must be disabled when using eslint-plugin-prettier: |
| 86 | + // See: https://github.com/prettier/eslint-plugin-prettier#arrow-body-style-and-prefer-arrow-callback-issue |
| 87 | + |
| 88 | + /** |
| 89 | + * https://eslint.org/docs/rules/arrow-body-style |
| 90 | + */ |
| 91 | + 'arrow-body-style': 'off', |
| 92 | + |
| 93 | + /** |
| 94 | + * https://eslint.org/docs/rules/prefer-arrow-callback |
| 95 | + */ |
| 96 | + 'prefer-arrow-callback': 'off', |
| 97 | + |
| 98 | + // ****************************************************************** |
| 99 | + // additions to base ruleset |
| 100 | + // ****************************************************************** |
| 101 | + |
| 102 | + // ---------------------------------- |
| 103 | + // ESLint |
| 104 | + // ---------------------------------- |
| 105 | + |
| 106 | + /** |
| 107 | + * https://eslint.org/docs/rules/id-denylist |
| 108 | + */ |
| 109 | + 'id-denylist': [ |
| 110 | + 'error', |
| 111 | + 'err', |
| 112 | + 'cb', |
| 113 | + 'callback', |
| 114 | + 'any', |
| 115 | + 'Number', |
| 116 | + 'number', |
| 117 | + 'String', |
| 118 | + 'string', |
| 119 | + 'Boolean', |
| 120 | + 'boolean', |
| 121 | + 'Undefined', |
| 122 | + 'undefined', |
| 123 | + ], |
| 124 | + |
| 125 | + // ---------------------------------- |
| 126 | + // @typescript-eslint |
| 127 | + // ---------------------------------- |
| 128 | + |
| 129 | + /** |
| 130 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md |
| 131 | + */ |
| 132 | + '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], |
| 133 | + |
| 134 | + /** |
| 135 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-ts-comment.md |
| 136 | + */ |
| 137 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 138 | + |
| 139 | + /** |
| 140 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md |
| 141 | + */ |
| 142 | + '@typescript-eslint/ban-types': [ |
| 143 | + 'error', |
| 144 | + { |
| 145 | + types: { |
| 146 | + Object: { |
| 147 | + message: 'Use object instead', |
| 148 | + fixWith: 'object', |
| 149 | + }, |
| 150 | + String: { |
| 151 | + message: 'Use string instead', |
| 152 | + fixWith: 'string', |
| 153 | + }, |
| 154 | + Boolean: { |
| 155 | + message: 'Use boolean instead', |
| 156 | + fixWith: 'boolean', |
| 157 | + }, |
| 158 | + Number: { |
| 159 | + message: 'Use number instead', |
| 160 | + fixWith: 'number', |
| 161 | + }, |
| 162 | + Symbol: { |
| 163 | + message: 'Use symbol instead', |
| 164 | + fixWith: 'symbol', |
| 165 | + }, |
| 166 | + Function: { |
| 167 | + message: [ |
| 168 | + 'The `Function` type accepts any function-like value.', |
| 169 | + 'It provides no type safety when calling the function, which can be a common source of bugs.', |
| 170 | + 'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.', |
| 171 | + 'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.', |
| 172 | + ].join('\n'), |
| 173 | + }, |
| 174 | + }, |
| 175 | + extendDefaults: false, |
| 176 | + }, |
| 177 | + ], |
| 178 | + |
| 179 | + /** |
| 180 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md |
| 181 | + */ |
| 182 | + '@typescript-eslint/consistent-type-assertions': 'error', |
| 183 | + |
| 184 | + /** |
| 185 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md |
| 186 | + */ |
| 187 | + '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }], |
| 188 | + |
| 189 | + /** |
| 190 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md |
| 191 | + */ |
| 192 | + '@typescript-eslint/member-delimiter-style': [ |
| 193 | + 'error', |
| 194 | + { |
| 195 | + multiline: { |
| 196 | + delimiter: 'semi', |
| 197 | + requireLast: true, |
| 198 | + }, |
| 199 | + singleline: { |
| 200 | + delimiter: 'semi', |
| 201 | + requireLast: false, |
| 202 | + }, |
| 203 | + }, |
| 204 | + ], |
| 205 | + |
| 206 | + /** |
| 207 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md |
| 208 | + */ |
| 209 | + '@typescript-eslint/naming-convention': [ |
| 210 | + 'error', |
| 211 | + { |
| 212 | + selector: 'default', |
| 213 | + format: ['camelCase'], |
| 214 | + }, |
| 215 | + { |
| 216 | + selector: 'variable', |
| 217 | + format: ['camelCase', 'snake_case', 'UPPER_CASE'], |
| 218 | + leadingUnderscore: 'allowSingleOrDouble', |
| 219 | + trailingUnderscore: 'allowSingleOrDouble', |
| 220 | + }, |
| 221 | + { |
| 222 | + selector: 'property', |
| 223 | + format: ['camelCase', 'snake_case'], |
| 224 | + leadingUnderscore: 'allowSingleOrDouble', |
| 225 | + trailingUnderscore: 'allowSingleOrDouble', |
| 226 | + }, |
| 227 | + { |
| 228 | + selector: 'typeLike', |
| 229 | + format: ['PascalCase'], |
| 230 | + }, |
| 231 | + { |
| 232 | + selector: ['method', 'function'], |
| 233 | + format: ['camelCase'], |
| 234 | + leadingUnderscore: 'allowSingleOrDouble', |
| 235 | + }, |
| 236 | + ], |
| 237 | + |
| 238 | + /** |
| 239 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-duplicate-imports.md |
| 240 | + */ |
| 241 | + '@typescript-eslint/no-duplicate-imports': 'error', |
| 242 | + |
| 243 | + /** |
| 244 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-invalid-void-type.md |
| 245 | + */ |
| 246 | + '@typescript-eslint/no-invalid-void-type': 'error', |
| 247 | + |
| 248 | + /** |
| 249 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-misused-promises.md |
| 250 | + */ |
| 251 | + '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }], |
| 252 | + |
| 253 | + /** |
| 254 | + * https://eslint.org/docs/1.0.0/rules/no-throw-literal |
| 255 | + */ |
| 256 | + '@typescript-eslint/no-throw-literal': 'error', |
| 257 | + |
| 258 | + /** |
| 259 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md |
| 260 | + */ |
| 261 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', |
| 262 | + |
| 263 | + /** |
| 264 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md |
| 265 | + */ |
| 266 | + '@typescript-eslint/no-unnecessary-qualifier': 'error', |
| 267 | + |
| 268 | + /** |
| 269 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md |
| 270 | + */ |
| 271 | + '@typescript-eslint/no-unused-expressions': 'error', |
| 272 | + |
| 273 | + /** |
| 274 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md |
| 275 | + */ |
| 276 | + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '_' }], |
| 277 | + |
| 278 | + /** |
| 279 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md |
| 280 | + */ |
| 281 | + '@typescript-eslint/prefer-nullish-coalescing': 'error', |
| 282 | + |
| 283 | + /** |
| 284 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md |
| 285 | + */ |
| 286 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 287 | + |
| 288 | + /** |
| 289 | + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/promise-function-async.md |
| 290 | + */ |
| 291 | + '@typescript-eslint/promise-function-async': 'error', |
| 292 | + |
| 293 | + // ---------------------------------- |
| 294 | + // eslint-plugin-import |
| 295 | + // ---------------------------------- |
| 296 | + |
| 297 | + /** |
| 298 | + * https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-default-export.md |
| 299 | + */ |
| 300 | + 'import/no-default-export': 'error', |
| 301 | + |
| 302 | + /** |
| 303 | + * https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md |
| 304 | + */ |
| 305 | + 'import/order': 'error', |
| 306 | + |
| 307 | + // ****************************************************************** |
| 308 | + // overrides to base ruleset |
| 309 | + // ****************************************************************** |
| 310 | + |
| 311 | + // ---------------------------------- |
| 312 | + // ESLint |
| 313 | + // ---------------------------------- |
| 314 | + |
| 315 | + /** |
| 316 | + * https://eslint.org/docs/rules/class-methods-use-this |
| 317 | + */ |
| 318 | + 'class-methods-use-this': 'off', |
| 319 | + |
| 320 | + /** |
| 321 | + * https://eslint.org/docs/rules/eqeqeq |
| 322 | + */ |
| 323 | + eqeqeq: 'error', |
| 324 | + |
| 325 | + /** |
| 326 | + * https://eslint.org/docs/rules/no-plusplus |
| 327 | + */ |
| 328 | + 'no-plusplus': 'off', |
| 329 | + |
| 330 | + /** |
| 331 | + * https://eslint.org/docs/rules/object-shorthand |
| 332 | + */ |
| 333 | + 'object-shorthand': 'error', |
| 334 | + |
| 335 | + /** |
| 336 | + * https://eslint.org/docs/rules/prefer-const |
| 337 | + */ |
| 338 | + 'prefer-const': 'error', |
| 339 | + |
| 340 | + /** |
| 341 | + * https://eslint.org/docs/rules/prefer-spread |
| 342 | + */ |
| 343 | + 'prefer-spread': 'error', |
| 344 | + |
| 345 | + // ---------------------------------- |
| 346 | + // import |
| 347 | + // ---------------------------------- |
| 348 | + |
| 349 | + /** |
| 350 | + * https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md |
| 351 | + */ |
| 352 | + 'import/prefer-default-export': 'off', |
| 353 | + }, |
| 354 | +}; |
0 commit comments