|
| 1 | +const esLintRules = { |
| 2 | + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
| 3 | + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
| 4 | + 'no-alert': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
| 5 | + 'no-template-curly-in-string': 'error', |
| 6 | + 'require-atomic-updates': 'error', |
| 7 | + curly: ['error', 'all'], |
| 8 | + eqeqeq: 'error', |
| 9 | + 'no-eval': 'error', |
| 10 | + 'require-await': 'error', |
| 11 | + strict: ['error', 'global'], |
| 12 | + 'no-restricted-imports': ['error', { patterns: ['**/dist/*'] }], |
| 13 | + indent: 'off', |
| 14 | + 'no-empty-function': 'off', |
| 15 | + 'no-unused-vars': 'off', |
| 16 | + 'no-extra-parens': 'off', |
| 17 | + 'no-unused-expressions': 'off' |
| 18 | +}; |
| 19 | + |
| 20 | +const tsLintRules = { |
| 21 | + '@typescript-eslint/indent': 'off', |
| 22 | + '@typescript-eslint/explicit-member-accessibility': [ |
| 23 | + 'error', |
| 24 | + { overrides: { methods: 'no-public', properties: 'off' } } |
| 25 | + ], |
| 26 | + '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }], |
| 27 | + '@typescript-eslint/no-explicit-any': 'off', |
| 28 | + '@typescript-eslint/no-use-before-define': ['off', { functions: false }], |
| 29 | + '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }], |
| 30 | + '@typescript-eslint/no-empty-function': ['error', { allow: ['protected-constructors'] }], |
| 31 | + '@typescript-eslint/no-parameter-properties': ['error', { allows: ['private', 'protected'] }], |
| 32 | + '@typescript-eslint/no-empty-interface': 'off', |
| 33 | + '@typescript-eslint/no-object-literal-type-assertion': 'off', |
| 34 | + '@typescript-eslint/no-extra-parens': ['error', 'all', { nestedBinaryExpressions: false }], |
| 35 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', |
| 36 | + '@typescript-eslint/no-unused-expressions': ['error'], |
| 37 | + // Type information rules |
| 38 | + '@typescript-eslint/no-unused-vars-experimental': 'error', |
| 39 | + '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }], |
| 40 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 41 | + '@typescript-eslint/prefer-nullish-coalescing': 'error' |
| 42 | +}; |
| 43 | + |
| 44 | +const vuePluginRules = { |
| 45 | + 'vue/attribute-hyphenation': 'off', |
| 46 | + 'vue/attributes-order': [ |
| 47 | + 'error', |
| 48 | + { |
| 49 | + order: [ |
| 50 | + 'DEFINITION', |
| 51 | + 'CONDITIONALS', |
| 52 | + 'LIST_RENDERING', |
| 53 | + 'UNIQUE', |
| 54 | + 'RENDER_MODIFIERS', |
| 55 | + 'TWO_WAY_BINDING', |
| 56 | + 'OTHER_DIRECTIVES', |
| 57 | + 'CONTENT', |
| 58 | + 'EVENTS', |
| 59 | + 'GLOBAL', |
| 60 | + 'OTHER_ATTR' |
| 61 | + ] |
| 62 | + } |
| 63 | + ], |
| 64 | + 'vue/no-v-html': 'off', |
| 65 | + 'vue/eqeqeq': 'error', |
| 66 | + 'vue/v-on-function-call': 'error' |
| 67 | +}; |
| 68 | + |
| 69 | +const importPluginRules = { |
| 70 | + 'import/no-self-import': 'error', |
| 71 | + 'import/no-unresolved': ['error', { ignore: ['^@.*'] }] |
| 72 | +}; |
| 73 | + |
| 74 | +const jestPluginRules = { |
| 75 | + 'jest/expect-expect': ['error', { assertFunctionNames: ['expect*'] }], |
| 76 | + 'jest/lowercase-name': ['error', { ignore: ['test'] }], |
| 77 | + 'jest/no-duplicate-hooks': 'error', |
| 78 | + 'jest/no-expect-resolves': 'error', |
| 79 | + 'jest/no-test-return-statement': 'error', |
| 80 | + 'jest/prefer-hooks-on-top': 'error', |
| 81 | + 'jest/require-top-level-describe': 'error', |
| 82 | + 'jest/valid-title': 'error' |
| 83 | +}; |
| 84 | + |
| 85 | + |
1 | 86 | module.exports = {
|
2 | 87 | root: true,
|
3 |
| - env: { |
4 |
| - node: true |
| 88 | + env: { node: true }, |
| 89 | + parserOptions: { |
| 90 | + parser: '@typescript-eslint/parser', |
| 91 | + project: './tsconfig.json', // required for rules that need type information |
| 92 | + extraFileExtensions: ['.vue'] |
5 | 93 | },
|
6 | 94 | extends: [
|
7 |
| - 'plugin:vue/recommended', |
| 95 | + 'eslint:recommended', |
| 96 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 97 | + 'plugin:@typescript-eslint/recommended', |
| 98 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
8 | 99 | 'plugin:prettier/recommended',
|
| 100 | + 'plugin:vue/recommended', |
9 | 101 | 'plugin:import/errors',
|
10 | 102 | 'plugin:import/warnings',
|
11 | 103 | 'plugin:import/typescript',
|
| 104 | + 'plugin:jest/recommended', |
| 105 | + 'plugin:jest/style', |
12 | 106 | '@vue/prettier',
|
13 | 107 | '@vue/typescript'
|
14 | 108 | ],
|
15 | 109 | rules: {
|
16 |
| - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
17 |
| - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
18 |
| - 'no-alert': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
19 | 110 | 'prettier/prettier': 'error',
|
20 |
| - 'vue/attribute-hyphenation': 'off', |
21 |
| - 'vue/attributes-order': [ |
22 |
| - 'error', |
23 |
| - { |
24 |
| - order: [ |
25 |
| - 'DEFINITION', |
26 |
| - 'CONDITIONALS', |
27 |
| - 'LIST_RENDERING', |
28 |
| - 'UNIQUE', |
29 |
| - 'RENDER_MODIFIERS', |
30 |
| - 'TWO_WAY_BINDING', |
31 |
| - 'OTHER_DIRECTIVES', |
32 |
| - 'CONTENT', |
33 |
| - 'EVENTS', |
34 |
| - 'GLOBAL', |
35 |
| - 'OTHER_ATTR' |
36 |
| - ] |
37 |
| - } |
38 |
| - ], |
39 |
| - 'vue/no-v-html': 'off', |
40 |
| - 'vue/arrow-spacing': 'error', |
41 |
| - 'vue/eqeqeq': 'error', |
42 |
| - 'vue/v-on-function-call': 'error', |
43 |
| - 'no-extra-parens': 'error', |
44 |
| - 'no-template-curly-in-string': 'error', |
45 |
| - 'require-atomic-updates': 'error', |
46 |
| - curly: ['error', 'all'], |
47 |
| - eqeqeq: 'error', |
48 |
| - 'no-eval': 'error', |
49 |
| - 'require-await': 'error', |
50 |
| - strict: ['error', 'global'], |
51 |
| - 'no-restricted-imports': ['error', { patterns: ['**/dist/*'] }], |
52 |
| - 'import/no-self-import': 'error', |
53 |
| - 'import/no-unresolved': ['error', { ignore: ['^@.*'] }] |
54 |
| - }, |
55 |
| - parserOptions: { |
56 |
| - parser: '@typescript-eslint/parser' |
| 111 | + ...esLintRules, |
| 112 | + ...tsLintRules, |
| 113 | + ...vuePluginRules, |
| 114 | + ...importPluginRules, |
| 115 | + ...jestPluginRules |
57 | 116 | },
|
58 | 117 | overrides: [
|
59 | 118 | {
|
|
0 commit comments