|
1 | 1 | module.exports = {
|
2 |
| - extends: [ |
3 |
| - 'plugin:@typescript-eslint/eslint-recommended', |
4 |
| - 'plugin:@typescript-eslint/recommended', |
5 |
| - 'prettier/@typescript-eslint', |
6 |
| - ], |
7 |
| - plugins: ['@typescript-eslint'], |
8 |
| - parser: '@typescript-eslint/parser', |
9 |
| - parserOptions: { |
10 |
| - ecmaVersion: 2019, |
11 |
| - sourceType: 'module', |
12 |
| - }, |
13 |
| - rules: { |
14 |
| - // Enforce explicit function return type |
15 |
| - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md |
16 |
| - '@typescript-eslint/explicit-function-return-type': 'off', |
17 |
| - |
18 |
| - // Prevent unused declared variables |
19 |
| - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md |
20 |
| - '@typescript-eslint/no-unused-vars': [ |
21 |
| - 'warn', |
22 |
| - { |
23 |
| - ignoreRestSiblings: true, |
24 |
| - argsIgnorePattern: '_+', |
25 |
| - }, |
26 |
| - ], |
27 |
| - |
28 |
| - // Enforce a consistent way of typing arrays |
29 |
| - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md |
30 |
| - // TODO https://github.com/vtex/javascript/issues/35 |
31 |
| - '@typescript-eslint/array-type': [ |
32 |
| - 'off', |
33 |
| - { |
34 |
| - default: 'array-simple', |
35 |
| - readonly: 'array-simple', |
| 2 | + overrides: [ |
| 3 | + { |
| 4 | + files: ['*.ts', '*.tsx'], |
| 5 | + extends: [ |
| 6 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 7 | + 'plugin:@typescript-eslint/recommended', |
| 8 | + 'prettier/@typescript-eslint', |
| 9 | + ], |
| 10 | + plugins: ['@typescript-eslint'], |
| 11 | + parser: '@typescript-eslint/parser', |
| 12 | + parserOptions: { |
| 13 | + ecmaVersion: 2019, |
| 14 | + sourceType: 'module', |
| 15 | + project: 'tsconfig.json', |
36 | 16 | },
|
37 |
| - ], |
| 17 | + rules: { |
| 18 | + // Enforce explicit function return type |
| 19 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md |
| 20 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 21 | + |
| 22 | + // Prevent unused declared variables |
| 23 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md |
| 24 | + '@typescript-eslint/no-unused-vars': [ |
| 25 | + 'warn', |
| 26 | + { |
| 27 | + ignoreRestSiblings: true, |
| 28 | + argsIgnorePattern: '_+', |
| 29 | + }, |
| 30 | + ], |
| 31 | + |
| 32 | + // Enforce a consistent way of typing arrays |
| 33 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md |
| 34 | + // TODO https://github.com/vtex/javascript/issues/35 |
| 35 | + '@typescript-eslint/array-type': [ |
| 36 | + 'off', |
| 37 | + { |
| 38 | + default: 'array-simple', |
| 39 | + readonly: 'array-simple', |
| 40 | + }, |
| 41 | + ], |
| 42 | + |
| 43 | + // Enforce a consitent way to type objects |
| 44 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md |
| 45 | + '@typescript-eslint/consistent-type-definitions': [ |
| 46 | + 'error', |
| 47 | + 'interface', |
| 48 | + ], |
| 49 | + |
| 50 | + // Disallow non null assertions (!), comes from the recommended config |
| 51 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md |
| 52 | + // TODO, maybe disable |
| 53 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 54 | + |
| 55 | + // Enforce that when adding two variables, operands must both be of type number or of type string |
| 56 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-plus-operands.md |
| 57 | + '@typescript-eslint/restrict-plus-operands': [ |
| 58 | + 'error', |
| 59 | + { |
| 60 | + checkCompoundAssignments: true, |
| 61 | + }, |
| 62 | + ], |
| 63 | + |
| 64 | + // Enforce optional chaining over chaining AND (&&) operators |
| 65 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md |
| 66 | + '@typescript-eslint/prefer-optional-chain': 'warn', |
| 67 | + |
| 68 | + // Enforce optional chaining over chaining AND (&&) operators |
| 69 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md |
| 70 | + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', |
| 71 | + |
| 72 | + // Enforce nullish coalescing over short-circuiting |
| 73 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md |
| 74 | + '@typescript-eslint/prefer-nullish-coalescing': [ |
| 75 | + 'warn', |
| 76 | + { |
| 77 | + ignoreConditionalTests: true, |
| 78 | + ignoreMixedLogicalExpressions: true, |
| 79 | + forceSuggestionFixer: false, |
| 80 | + }, |
| 81 | + ], |
38 | 82 |
|
39 |
| - // Enforce a consitent way to type objects |
40 |
| - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md |
41 |
| - '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], |
| 83 | + // Prefer usage of as const over literal type |
| 84 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-as-const.md |
| 85 | + // TODO: turn it on when 2.18.x is out |
| 86 | + // '@typescript-eslint/prefer-as-const': 'error', |
42 | 87 |
|
43 |
| - // Disallow non null assertions (!), comes from the recommended config |
44 |
| - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md |
45 |
| - // TODO, maybe disable |
46 |
| - '@typescript-eslint/no-non-null-assertion': 'warn', |
47 |
| - }, |
| 88 | + // Prevent unnecessary type arguments |
| 89 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md |
| 90 | + '@typescript-eslint/no-unnecessary-type-arguments': 'warn', |
| 91 | + |
| 92 | + // Warns when a namespace qualifier is unnecessary |
| 93 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md |
| 94 | + '@typescript-eslint/no-unnecessary-qualifier': 'warn', |
| 95 | + |
| 96 | + // Disallow throwing literals as exceptions |
| 97 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md |
| 98 | + '@typescript-eslint/no-throw-literal': 'warn', |
| 99 | + |
| 100 | + // Disallows invocation of require() in favor of import statements |
| 101 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-require-imports.md |
| 102 | + '@typescript-eslint/no-require-imports': 'warn', |
| 103 | + |
| 104 | + // Disallows the use of eval()-like methods |
| 105 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md |
| 106 | + '@typescript-eslint/no-implied-eval': 'error', |
| 107 | + |
| 108 | + // Disallows the use of eval()-like methods |
| 109 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md |
| 110 | + 'no-magic-numbers': 'off', |
| 111 | + '@typescript-eslint/no-magic-numbers': [ |
| 112 | + 'warn', |
| 113 | + { |
| 114 | + ignoreNumericLiteralTypes: true, |
| 115 | + ignoreEnums: true, |
| 116 | + }, |
| 117 | + ], |
| 118 | + |
| 119 | + // Enforce parameters with default values to be last |
| 120 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/default-param-last.md |
| 121 | + 'default-param-last': 'off', |
| 122 | + '@typescript-eslint/default-param-last': 'error', |
| 123 | + |
| 124 | + // Disallow useless constructors |
| 125 | + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md |
| 126 | + 'no-useless-constructor': 'off', |
| 127 | + '@typescript-eslint/no-useless-constructor': 'error', |
| 128 | + }, |
| 129 | + }, |
| 130 | + ], |
48 | 131 | }
|
0 commit comments