|
| 1 | +// https://eslint.org/docs/latest/use/configure/ |
| 2 | + |
1 | 3 | module.exports = { |
| 4 | + root: true, |
2 | 5 | env: { |
| 6 | + // @TODO: Can be removed, ES versions are cumulative: |
| 7 | + // https://stackoverflow.com/a/61688878 |
| 8 | + // es6: true, |
| 9 | + // This seems to be what Node.js 18, 20 fully supports, but online documentation |
| 10 | + // isn't exactly crystal clear about what should be put here |
| 11 | + es2022: true, |
3 | 12 | browser: true, |
4 | | - es6: true, |
5 | | - es2020: true, |
6 | | - 'jest/globals': true, |
7 | 13 | node: true, |
8 | | - jasmine: true, |
9 | 14 | }, |
| 15 | + // Standard linting for pure javascript files |
| 16 | + parserOptions: { |
| 17 | + // @TODO: Can be removed, as env ES version sets this too: |
| 18 | + // https://eslint.org/docs/latest/use/configure/language-options#specifying-environments |
| 19 | + // ecmaVersion: 2019, |
| 20 | + // @TODO: Remove because in JS files we use commonjs |
| 21 | + // sourceType: 'module', |
| 22 | + }, |
| 23 | + // prettier must always be put last, so it overrides anything before it |
10 | 24 | extends: [ |
11 | 25 | 'eslint:recommended', |
12 | | - 'plugin:@typescript-eslint/recommended', |
13 | | - 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
14 | | - 'plugin:prettier/recommended', |
| 26 | + // Disables all style rules |
| 27 | + // https://prettier.io/docs/en/integrating-with-linters.html |
| 28 | + // https://github.com/prettier/eslint-config-prettier |
| 29 | + 'prettier', |
15 | 30 | ], |
16 | | - parser: '@typescript-eslint/parser', |
17 | | - parserOptions: { |
18 | | - ecmaVersion: 2019, |
19 | | - project: ['tsconfig.eslint.json'], |
20 | | - sourceType: 'module', |
21 | | - projectFolderIgnoreList: ['dist'], |
22 | | - }, |
23 | | - plugins: ['tsdoc', '@typescript-eslint', 'prettier', 'jest'], |
24 | 31 | rules: { |
25 | | - 'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions |
26 | | - 'prettier/prettier': ['error', {}, { usePrettierrc: true }], |
27 | | - '@typescript-eslint/array-type': ['warn', { default: 'array-simple' }], |
28 | | - '@typescript-eslint/return-await': 'off', |
29 | | - 'tsdoc/syntax': 'error', |
30 | | - '@typescript-eslint/space-before-function-paren': 0, |
31 | | - '@typescript-eslint/no-explicit-any': 'off', |
32 | | - '@typescript-eslint/explicit-function-return-type': 'off', |
33 | | - '@typescript-eslint/no-throw-literal': 'off', |
34 | | - '@typescript-eslint/no-unused-vars': [ |
35 | | - 'error', |
36 | | - // argsIgnorePattern: arguments whose names match a regexp pattern |
37 | | - // varsIgnorePattern: variables whose names match a regexp pattern |
38 | | - { args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
39 | | - ], |
40 | | - '@typescript-eslint/member-delimiter-style': [ |
41 | | - 'error', |
42 | | - { |
43 | | - multiline: { |
44 | | - delimiter: 'none', // 'none' or 'semi' or 'comma' |
45 | | - requireLast: true, |
46 | | - }, |
47 | | - singleline: { |
48 | | - delimiter: 'semi', // 'semi' or 'comma' |
49 | | - requireLast: false, |
50 | | - }, |
51 | | - }, |
52 | | - ], |
53 | | - 'comma-dangle': 'off', |
54 | | - '@typescript-eslint/ban-ts-ignore': 'off', |
| 32 | + // @TODO: Remove this rule, as it's a style rule covered by prettier and |
| 33 | + // it's deprecated https://eslint.org/docs/latest/rules/comma-dangle |
| 34 | + // 'comma-dangle': 'off', |
55 | 35 | }, |
| 36 | + overrides: [ |
| 37 | + // TypeScript linting for TypeScript files |
| 38 | + { |
| 39 | + files: '*.ts', |
| 40 | + plugins: [ |
| 41 | + '@typescript-eslint', |
| 42 | + // TSDoc is only meant for TS files https://tsdoc.org/ |
| 43 | + 'eslint-plugin-tsdoc', |
| 44 | + ], |
| 45 | + parser: '@typescript-eslint/parser', |
| 46 | + parserOptions: { project: 'tsconfig.eslint.json' }, |
| 47 | + // prettier must always be put last, so it overrides anything before it |
| 48 | + extends: [ |
| 49 | + 'plugin:@typescript-eslint/recommended-type-checked', |
| 50 | + 'prettier', |
| 51 | + ], |
| 52 | + rules: { |
| 53 | + // @TODO: Remove as it doesn't seem to cause issues anymore with fn overloads |
| 54 | + // 'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions |
| 55 | + 'tsdoc/syntax': 'error', |
| 56 | + // new TS rules begin @TODO: Remove these and adapt code |
| 57 | + '@typescript-eslint/prefer-as-const': 'off', |
| 58 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 59 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 60 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 61 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 62 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 63 | + '@typescript-eslint/no-unsafe-argument': 'off', |
| 64 | + '@typescript-eslint/no-floating-promises': 'off', |
| 65 | + // new TS rules end |
| 66 | + '@typescript-eslint/array-type': ['warn', { default: 'array-simple' }], |
| 67 | + // @TODO: Remove, as it's already off |
| 68 | + // '@typescript-eslint/return-await': 'off', |
| 69 | + // @TODO: Remove this rule, deprecated: |
| 70 | + // https://typescript-eslint.io/rules/space-before-function-paren/ |
| 71 | + // '@typescript-eslint/space-before-function-paren': 0, |
| 72 | + // @TODO: Should be careful with this rule, should leave it be and disable |
| 73 | + // it within files where necessary with explanations |
| 74 | + '@typescript-eslint/no-explicit-any': 'off', |
| 75 | + // @TODO: Remove, as it's already off |
| 76 | + // '@typescript-eslint/explicit-function-return-type': 'off', |
| 77 | + // @TODO: Remove, as it's already off |
| 78 | + // '@typescript-eslint/no-throw-literal': 'off', |
| 79 | + '@typescript-eslint/no-unused-vars': [ |
| 80 | + 'error', |
| 81 | + // argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern |
| 82 | + // varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern |
| 83 | + { args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
| 84 | + ], |
| 85 | + // @TODO: Remove this rule, as it's a style rule covered by prettier |
| 86 | + // '@typescript-eslint/member-delimiter-style': [ |
| 87 | + // 'error', |
| 88 | + // { |
| 89 | + // multiline: { |
| 90 | + // delimiter: 'none', // 'none' or 'semi' or 'comma' |
| 91 | + // requireLast: true, |
| 92 | + // }, |
| 93 | + // singleline: { |
| 94 | + // delimiter: 'semi', // 'semi' or 'comma' |
| 95 | + // requireLast: false, |
| 96 | + // }, |
| 97 | + // }, |
| 98 | + // ], |
| 99 | + // @TODO: Not recommended to disable rule, should instead disable locally |
| 100 | + // with explanation |
| 101 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 102 | + }, |
| 103 | + }, |
| 104 | + // Jest linting for test files |
| 105 | + { |
| 106 | + files: 'tests/*.ts', |
| 107 | + plugins: ['jest'], |
| 108 | + env: { |
| 109 | + // @TODO: Jasmine is not meant to be used in Jest tests, |
| 110 | + // there's even a rule for it in plugin:jest/recommended |
| 111 | + jasmine: true, |
| 112 | + jest: true, |
| 113 | + 'jest/globals': true, |
| 114 | + }, |
| 115 | + // prettier must always be put last, so it overrides anything before it |
| 116 | + extends: ['plugin:jest/recommended', 'prettier'], |
| 117 | + // @TODO: Remove these rules and adapt code! |
| 118 | + rules: { |
| 119 | + 'jest/no-disabled-tests': 'off', |
| 120 | + 'jest/expect-expect': 'off', |
| 121 | + 'jest/no-conditional-expect': 'off', |
| 122 | + 'jest/valid-title': 'off', |
| 123 | + 'jest/no-jasmine-globals': 'off', |
| 124 | + 'jest/valid-expect-in-promise': 'off', |
| 125 | + 'jest/valid-expect': 'off', |
| 126 | + 'jest/no-alias-methods': 'off', |
| 127 | + }, |
| 128 | + }, |
| 129 | + ], |
56 | 130 | } |
0 commit comments