forked from FloEdelmann/vue-ts-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
178 lines (174 loc) · 6.58 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* eslint-disable unicorn/prefer-module */
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:unicorn/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: [
'@typescript-eslint',
],
rules: {
// Core ESLint rules
'accessor-pairs': 'error',
'array-bracket-spacing': 'error',
'arrow-parens': ['error', 'as-needed'],
'arrow-spacing': 'error',
'block-spacing': 'error',
'brace-style': ['error', 'stroustrup'],
'camelcase': 'error',
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
'consistent-return': 'error',
'curly': ['error', 'all'],
'dot-location': ['error', 'property'],
'dot-notation': 'error',
'eol-last': 'error',
'eqeqeq': 'error',
'func-call-spacing': 'error',
'getter-return': 'error',
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
'guard-for-in': 'error',
'indent': 'off', // replaced by @typescript-eslint/indent
'key-spacing': 'error',
'keyword-spacing': 'error',
'linebreak-style': ['error', 'unix'],
'new-parens': 'error',
'no-array-constructor': 'error',
'no-bitwise': 'error',
'no-confusing-arrow': ['error', { allowParens: true }],
'no-constant-binary-expression': 'error',
'no-constant-condition': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-irregular-whitespace': 'error',
'no-lonely-if': 'error',
'no-loop-func': 'error',
'no-mixed-operators': 'error',
'no-multi-spaces': 'error',
'no-new-object': 'error',
'no-prototype-builtins': 'error',
'no-return-assign': 'error',
'no-return-await': 'error',
'no-shadow': 'off', // replaced by @typescript-eslint/no-shadow
'no-template-curly-in-string': 'error',
'no-trailing-spaces': 'error',
'no-unsafe-optional-chaining': ['error', { 'disallowArithmeticOperators': true }],
'no-var': 'error',
'object-curly-spacing': 'off', // replaced by @typescript-eslint/object-curly-spacing
'object-shorthand': ['error', 'always', { avoidQuotes: true }],
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-rest-params': 'error',
'prefer-template': 'error',
'quotes': ['error', 'single'],
'radix': 'error',
'semi': 'error',
'space-before-blocks': 'error',
'space-before-function-paren': ['error', {
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
}],
'space-in-parens': 'error',
'space-infix-ops': 'off', // replaced by @typescript-eslint/space-infix-ops
'spaced-comment': 'error',
'space-unary-ops': 'error',
'template-curly-spacing': 'error',
// eslint-plugin-unicorn
'unicorn/filename-case': 'off',
'unicorn/no-useless-undefined': 'off', // conflicts with consistent-return
'unicorn/prevent-abbreviations': ['warn', {
replacements: {
prop: false,
},
}],
// @typescript-eslint/eslint-plugin
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': ['error', {
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow-as-parameter',
}],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-void-expression': ['error', {
ignoreVoidOperator: true,
ignoreArrowShorthand: true,
}],
'@typescript-eslint/no-duplicate-imports': 'error',
'@typescript-eslint/no-explicit-any': 'off', // needed for Vue types compatibility
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-shadow': ['warn', { ignoreOnInitialization: true }],
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/object-curly-spacing': ['error', 'always'],
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/sort-type-union-intersection-members': 'warn',
'@typescript-eslint/space-infix-ops': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
},
ignorePatterns: [
'**/*.json',
'node_modules',
'dist',
],
overrides: [
{
files: ['tests/**'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
// additional Jest rules
'jest/consistent-test-it': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-called-with': 'warn',
'jest/prefer-comparison-matcher': 'warn',
'jest/prefer-equality-matcher': 'warn',
'jest/prefer-expect-resolves': 'warn',
'jest/prefer-hooks-on-top': 'warn',
'jest/prefer-spy-on': 'warn',
'jest/prefer-strict-equal': 'warn',
'jest/require-to-throw-message': 'warn',
'jest/require-top-level-describe': 'warn',
// less strict other rules
'unicorn/no-null': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
},
},
],
};