-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
243 lines (237 loc) · 10 KB
/
.eslintrc.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
const ERROR = 2;
const OFF = 0;
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
ecmaVersion: 6,
jsxPragma: null,
},
reportUnusedDisableDirectives: true,
plugins: ['import'],
settings: {
'import/parsers': { '@typescript-eslint/parser': ['.ts'] },
'import/resolver': { node: { extensions: ['.ts', '.js', '.json'] }, typescript: {} },
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'plugin:import/errors',
'plugin:unicorn/recommended',
'plugin:prettier/recommended',
'plugin:eslint-plugin/all',
],
rules: {
'array-callback-return': ERROR,
'arrow-body-style': ERROR,
'consistent-return': [ERROR, { treatUndefinedAsUnspecified: true }],
curly: ERROR,
'default-case': ERROR,
eqeqeq: ERROR,
'guard-for-in': ERROR,
'lines-between-class-members': ERROR,
'max-lines': ERROR,
'no-bitwise': ERROR,
'no-caller': ERROR,
'no-case-declarations': ERROR,
'no-console': ERROR,
'no-constant-binary-expression': ERROR,
'no-constructor-return': ERROR,
'no-else-return': ERROR,
'no-eval': ERROR,
'no-extend-native': ERROR,
'no-extra-bind': ERROR,
'no-floating-decimal': ERROR,
'no-implicit-coercion': [ERROR, { allow: ['!!'] }],
'no-invalid-this': ERROR,
'no-iterator': ERROR,
'no-lone-blocks': ERROR,
'no-lonely-if': ERROR,
'no-loop-func': ERROR,
'no-multi-assign': ERROR,
'no-nested-ternary': ERROR,
'no-new': ERROR,
'no-new-func': ERROR,
'no-new-wrappers': ERROR,
'no-param-reassign': ERROR,
'no-path-concat': ERROR,
'no-plusplus': [ERROR, { allowForLoopAfterthoughts: true }],
'no-process-exit': ERROR,
'no-proto': ERROR,
'no-return-assign': ERROR,
'no-script-url': ERROR,
'no-self-compare': ERROR,
'no-shadow': ERROR,
'no-template-curly-in-string': ERROR,
'no-undef-init': ERROR,
'no-underscore-dangle': [ERROR, { allowAfterThis: true, allowAfterSuper: true }],
'no-unmodified-loop-condition': ERROR,
'no-unneeded-ternary': [ERROR, { defaultAssignment: false }],
'no-useless-call': ERROR,
'no-useless-computed-key': ERROR,
'no-useless-concat': ERROR,
'no-useless-return': ERROR,
'no-void': ERROR,
'object-shorthand': ERROR,
'one-var': [ERROR, 'never'],
'operator-assignment': ERROR,
'padding-line-between-statements': [
ERROR,
// Always require blank lines after directive (like 'use-strict'), except between directives
{ blankLine: 'always', prev: 'directive', next: '*' },
{ blankLine: 'any', prev: 'directive', next: 'directive' },
// Always require blank lines after import, except between imports
{ blankLine: 'always', prev: 'import', next: '*' },
{ blankLine: 'any', prev: 'import', next: 'import' },
// Always require blank lines before and after every sequence of variable declarations and export
{ blankLine: 'always', prev: '*', next: ['const', 'let', 'var', 'export'] },
{ blankLine: 'always', prev: ['const', 'let', 'var', 'export'], next: '*' },
{ blankLine: 'any', prev: ['const', 'let', 'var', 'export'], next: ['const', 'let', 'var', 'export'] },
// Always require blank lines before and after class declaration, if, do/while, switch, try
{ blankLine: 'always', prev: '*', next: ['if', 'class', 'for', 'do', 'while', 'switch', 'try'] },
{ blankLine: 'always', prev: ['if', 'class', 'for', 'do', 'while', 'switch', 'try'], next: '*' },
// Always require blank lines before return statements
{ blankLine: 'always', prev: '*', next: 'return' },
],
'prefer-destructuring': ERROR,
'prefer-exponentiation-operator': ERROR,
'prefer-numeric-literals': ERROR,
'prefer-promise-reject-errors': ERROR,
'prefer-regex-literals': ERROR,
'prefer-template': ERROR,
'quote-props': [ERROR, 'as-needed'],
radix: ERROR,
'spaced-comment': ERROR,
'sort-imports': [ERROR, { ignoreDeclarationSort: true }],
strict: ERROR,
yoda: ERROR,
'@typescript-eslint/array-type': ERROR,
'@typescript-eslint/consistent-indexed-object-style': ERROR,
'@typescript-eslint/consistent-type-definitions': ERROR,
'@typescript-eslint/consistent-type-imports': ERROR,
'@typescript-eslint/class-literal-property-style': ERROR,
'@typescript-eslint/default-param-last': ERROR,
'@typescript-eslint/explicit-function-return-type': [ERROR, { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': [ERROR, { accessibility: 'no-public' }],
'@typescript-eslint/explicit-module-boundary-types': ERROR,
'@typescript-eslint/method-signature-style': ERROR,
'@typescript-eslint/no-duplicate-enum-values': ERROR,
'@typescript-eslint/no-empty-interface': [ERROR, { allowSingleExtends: true }],
'@typescript-eslint/no-extraneous-class': ERROR,
'@typescript-eslint/no-invalid-void-type': ERROR,
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': ERROR,
'@typescript-eslint/no-unused-expressions': [ERROR, { allowTernary: true }],
'@typescript-eslint/no-unused-vars': [ERROR, { ignoreRestSiblings: true }],
'@typescript-eslint/no-use-before-define': ERROR,
'@typescript-eslint/no-useless-constructor': ERROR,
'@typescript-eslint/no-useless-empty-export': ERROR,
'@typescript-eslint/parameter-properties': ERROR,
'@typescript-eslint/prefer-for-of': ERROR,
'@typescript-eslint/prefer-function-type': ERROR,
'@typescript-eslint/prefer-optional-chain': ERROR,
'@typescript-eslint/prefer-ts-expect-error': ERROR,
'@typescript-eslint/sort-type-union-intersection-members': ERROR,
'@typescript-eslint/unified-signatures': ERROR,
'@typescript-eslint/consistent-type-exports': ERROR,
'@typescript-eslint/dot-notation': ERROR,
'@typescript-eslint/naming-convention': [
ERROR,
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
filter: { regex: '^process\\.env\\.[A-Z][A-Z_]*$', match: false },
},
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'typeAlias', format: ['PascalCase'], custom: { regex: '^I[A-Z]', match: false } },
{ selector: 'interface', format: ['PascalCase'], prefix: ['I'] },
],
'@typescript-eslint/no-base-to-string': ERROR,
'@typescript-eslint/no-confusing-void-expression': ERROR,
'@typescript-eslint/no-meaningless-void-operator': ERROR,
'@typescript-eslint/no-redundant-type-constituents': ERROR,
'@typescript-eslint/no-throw-literal': ERROR,
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ERROR,
'@typescript-eslint/no-unnecessary-type-arguments': ERROR,
'@typescript-eslint/non-nullable-type-assertion-style': OFF,
'@typescript-eslint/prefer-nullish-coalescing': ERROR,
'@typescript-eslint/prefer-readonly': ERROR,
'@typescript-eslint/prefer-reduce-type-parameter': ERROR,
'@typescript-eslint/prefer-regexp-exec': ERROR,
'@typescript-eslint/prefer-return-this-type': ERROR,
'@typescript-eslint/require-array-sort-compare': ERROR,
'@typescript-eslint/return-await': ERROR,
'@typescript-eslint/switch-exhaustiveness-check': ERROR,
'eslint-plugin/require-meta-docs-url': OFF,
'import/extensions': [ERROR, { json: 'always' }],
'import/first': ERROR,
'import/named': ERROR,
'import/namespace': ERROR,
'import/newline-after-import': ERROR,
'import/no-cycle': ERROR,
'import/no-default-export': ERROR,
'import/no-duplicates': ERROR,
'import/no-extraneous-dependencies': ERROR,
'import/no-unresolved': ERROR,
'import/no-useless-path-segments': ERROR,
'import/order': [
ERROR,
{ alphabetize: { order: 'asc' }, 'newlines-between': 'always', warnOnUnassignedImports: true },
],
'unicorn/better-regex': ERROR,
'unicorn/catch-error-name': ERROR,
'unicorn/consistent-function-scoping': ERROR,
'unicorn/explicit-length-check': ERROR,
'unicorn/filename-case': ERROR,
'unicorn/import-index': ERROR,
'unicorn/import-style': ERROR,
'unicorn/no-array-for-each': OFF,
'unicorn/no-array-reduce': OFF,
'unicorn/no-array-callback-reference': ERROR,
'unicorn/no-null': OFF,
'unicorn/no-object-as-default-parameter': ERROR,
'unicorn/no-process-exit': ERROR,
'unicorn/no-unreadable-array-destructuring': ERROR,
'unicorn/no-useless-undefined': ERROR,
'unicorn/prefer-add-event-listener': ERROR,
'unicorn/prefer-array-flat': ERROR,
'unicorn/prefer-module': OFF,
'unicorn/prefer-negative-index': ERROR,
'unicorn/prefer-node-protocol': OFF,
'unicorn/prefer-number-properties': ERROR,
'unicorn/prefer-object-from-entries': ERROR,
'unicorn/prefer-optional-catch-binding': ERROR,
'unicorn/prefer-query-selector': ERROR,
'unicorn/prefer-set-has': ERROR,
'unicorn/prefer-spread': ERROR,
'unicorn/prefer-string-slice': ERROR,
'unicorn/prefer-ternary': ERROR,
'unicorn/prevent-abbreviations': OFF,
'unicorn/template-indent': ERROR,
},
overrides: [
{ files: ['./.commitlintrc.js', './.eslintrc.js', './.prettierrc.js'], rules: { 'no-undef': OFF } },
{
files: ['./.eslintrc.js', './src/index.ts', './src/configs/*.ts'],
rules: { '@typescript-eslint/naming-convention': OFF },
},
{
files: [
'./src/configs/recommended*.ts',
'./src/rules/*.ts',
'./src/rules/*/index.ts',
'./src/rules/no-deprecated-api/no-deprecated-api.ts',
'./src/rules/no-unsupported-features/*.ts',
'./src/rules/prefer-global/*.ts',
'./src/rules/prefer-promises/*.ts',
'./src/index.ts',
],
rules: { 'import/no-default-export': OFF },
},
{ files: ['./scripts/*.ts', './tests/**/*.ts'], rules: { 'no-console': OFF } },
{ files: ['./src/index.ts'], rules: { 'max-lines': OFF } },
],
};