-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
190 lines (187 loc) · 8.28 KB
/
eslint.config.js
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
179
180
181
182
183
184
185
186
187
188
189
190
import pluginJs from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';
import tsdoclint from 'eslint-plugin-tsdoc';
export default [
pluginJs.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylistic,
{
plugins: {
'@stylistic': stylistic,
tsdoc: tsdoclint
},
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
},
rules: {
/**
* TsDoc rules
*/
'tsdoc/syntax': 'warn',
/**
* Stylistic rules
* @see https://eslint.style/packages/default#rules
*/
'@stylistic/array-bracket-newline': ['error', 'consistent'],
'@stylistic/array-bracket-spacing': ['error', 'never'],
'@stylistic/array-element-newline': ['error', 'consistent'],
'@stylistic/arrow-parens': ['error', 'always'],
'@stylistic/arrow-spacing': 'error',
'@stylistic/block-spacing': 'error',
'@stylistic/brace-style': 'error', // style 1tbs
'@stylistic/comma-dangle': ['error', 'never'],
'@stylistic/comma-spacing': ['error', {
before: false,
after: true
}],
'@stylistic/comma-style': ['error', 'last'],
'@stylistic/curly-newline': ['error', { consistent: true }],
'@stylistic/function-call-spacing': ['error', 'never'],
'@stylistic/function-paren-newline': ['error', 'consistent'],
'@stylistic/generator-star-spacing': ['error', {
before: true,
after: false
}],
'@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
'@stylistic/indent': ['error', 4],
'@stylistic/indent-binary-ops': ['error', 4],
'@stylistic/key-spacing': ['error', { beforeColon: false }],
'@stylistic/keyword-spacing': ['error', { before: true }],
'@stylistic/lines-between-class-members': ['error', 'always'],
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
'@stylistic/new-parens': 'error',
'@stylistic/no-confusing-arrow': 'error',
'@stylistic/no-extra-semi': 'error',
'@stylistic/no-floating-decimal': 'error',
'@stylistic/no-mixed-operators': 'error',
'@stylistic/no-mixed-spaces-and-tabs': 'error',
'@stylistic/no-multi-spaces': 'error',
'@stylistic/no-tabs': 'error',
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/no-whitespace-before-property': 'error',
'@stylistic/operator-linebreak': ['error', 'before'],
'@stylistic/padded-blocks': ['error', 'never'],
'@stylistic/quote-props': ['error', 'as-needed'],
'@stylistic/quotes': ['error', 'single'],
'@stylistic/rest-spread-spacing': ['error', 'never'],
'@stylistic/semi': 'error',
'@stylistic/semi-spacing': 'error',
'@stylistic/semi-style': ['error', 'last'],
'@stylistic/space-before-blocks': 'error',
'@stylistic/space-in-parens': ['error', 'never'],
'@stylistic/space-unary-ops': 'error',
'@stylistic/spaced-comment': ['error', 'always'],
'@stylistic/template-curly-spacing': 'error',
'@stylistic/template-tag-spacing': 'error',
'@stylistic/type-annotation-spacing': 'error', // create issue because on doc is stylistic/ts/type-annotation-spacing
'@stylistic/type-generic-spacing': ['error'],
'@stylistic/type-named-tuple-spacing': ['error']
}
},
{
rules: {
/**
* EsLint rules not included in recommended
* @see https://eslint.org/docs/rules/
*/
'array-callback-return': 'error',
'no-constructor-return': 'error',
'no-duplicate-imports': 'error',
'no-self-compare': 'error',
'no-template-curly-in-string': 'error',
'no-unmodified-loop-condition': 'error',
'no-unreachable-loop': 'error',
'no-use-before-define': 'error',
// 'no-useless-assignement': 'error',
'arrow-body-style': ['error', 'as-needed'],
'block-scoped-var': 'error',
camelcase: 'error',
complexity: ['error', 25],
'consistent-return': 'error',
curly: ['error', 'multi', 'consistent'],
'default-param-last': 'error',
'max-classes-per-file': ['error', 1],
'max-depth': ['error', 4],
'new-cap': 'error',
'no-else-return': 'error',
'no-empty-function': 'error',
'no-invalid-this': 'error',
'no-lonely-if': 'error',
'no-unused-expressions': 'error',
'no-useless-concat': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'off',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'operator-assignment': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-destructuring': 'error',
'prefer-exponentiation-operator': 'error',
'prefer-object-has-own': 'error',
'prefer-object-spread': 'error',
'require-await': 'error',
'object-curly-spacing': ['error', 'always']
}
},
{
languageOptions: {
parserOptions: {
projectService: { allowDefaultProject: ['*.js', '*.mjs'] },
parser: tseslint.parser,
tsconfigRootDir: import.meta.dirname
}
},
rules: {
/**
* TypeScript rules not included in strictTypeChecked and stylistic
* @see https://typescript-eslint.io/rules/
*/
'consistent-return': 'off',
'@typescript-eslint/consistent-return': 'error',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'separate-type-imports' }],
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error', { accessibility: 'explicit' }
],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'max-params': 'off',
'@typescript-eslint/max-params': [
'error', { max: 6 }
],
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'prefer-destructuring': 'off',
'@typescript-eslint/prefer-destructuring': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-readonly-parameter-types': 'off', // error is not working
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
/**
* TypeScript disabled rules in strictTypeChecked and stylistic
*/
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
'@typescript-eslint/no-dynamic-delete': 'off'
}
}
];