@crycode/eslint-config 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/eslint-config.js +397 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# ESLint config
|
|
2
|
+
|
|
3
|
+
This modules provides an ESLint configuration to be used with TypeScript
|
|
4
|
+
according to my personal preferences.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Add `eslint` and `@crycode/eslint-config` to your devDependencies:
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
npm install --save-dev eslint @crycode/eslint-config
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Add a file named `.eslintrc.js` to your project root directory:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
module.exports = {
|
|
18
|
+
extends: [
|
|
19
|
+
'@crycode/eslint-config'
|
|
20
|
+
],
|
|
21
|
+
parserOptions: {
|
|
22
|
+
project: [
|
|
23
|
+
'./tsconfig.json',
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If you habe multiple tsconfig files, add them all to `project` like this:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
module.exports = {
|
|
33
|
+
extends: [
|
|
34
|
+
'@crycode/eslint-config'
|
|
35
|
+
],
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: [
|
|
38
|
+
'./tsconfig.backend.json',
|
|
39
|
+
'./tsconfig.frontend.json',
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Changelog
|
|
46
|
+
|
|
47
|
+
<!--
|
|
48
|
+
Placeholder for the next version (at the beginning of the line):
|
|
49
|
+
### **WORK IN PROGRESS**
|
|
50
|
+
-->
|
|
51
|
+
### 1.0.0 (2022-07-26)
|
|
52
|
+
|
|
53
|
+
* First release
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT License
|
|
58
|
+
|
|
59
|
+
Copyright (c) 2021-2022 Peter Müller <peter@crycode.de>
|
|
60
|
+
|
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
62
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
63
|
+
in the Software without restriction, including without limitation the rights
|
|
64
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
65
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
66
|
+
furnished to do so, subject to the following conditions:
|
|
67
|
+
|
|
68
|
+
The above copyright notice and this permission notice shall be included in all
|
|
69
|
+
copies or substantial portions of the Software.
|
|
70
|
+
|
|
71
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
72
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
73
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
74
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
75
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
76
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
77
|
+
SOFTWARE.
|
package/eslint-config.js
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint configuration to be used with TypeScript according to my
|
|
3
|
+
* personal preferences.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
parser: '@typescript-eslint/parser',
|
|
8
|
+
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2021,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
project: [
|
|
13
|
+
'./tsconfig.json'
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
extends: [
|
|
18
|
+
'plugin:@typescript-eslint/recommended',
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
plugins: [],
|
|
22
|
+
|
|
23
|
+
ignorePatterns: [
|
|
24
|
+
'/build/*',
|
|
25
|
+
'/dist/*',
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
rules: {
|
|
29
|
+
|
|
30
|
+
'array-bracket-spacing': ['warn', 'always'],
|
|
31
|
+
|
|
32
|
+
'array-callback-return': 'warn',
|
|
33
|
+
|
|
34
|
+
'arrow-parens': ['warn', 'always'],
|
|
35
|
+
|
|
36
|
+
'arrow-spacing': 'warn',
|
|
37
|
+
|
|
38
|
+
'brace-style': 'off',
|
|
39
|
+
'@typescript-eslint/brace-style': [
|
|
40
|
+
'error',
|
|
41
|
+
'1tbs',
|
|
42
|
+
{
|
|
43
|
+
allowSingleLine: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
'comma-dangle': 'off',
|
|
48
|
+
'@typescript-eslint/comma-dangle': [
|
|
49
|
+
'warn',
|
|
50
|
+
{
|
|
51
|
+
arrays: 'always-multiline',
|
|
52
|
+
objects: 'always-multiline',
|
|
53
|
+
imports: 'always-multiline',
|
|
54
|
+
exports: 'always-multiline',
|
|
55
|
+
functions: 'always-multiline',
|
|
56
|
+
enums: 'always-multiline',
|
|
57
|
+
generics: 'always-multiline',
|
|
58
|
+
tuples: 'always-multiline',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
|
|
62
|
+
'comma-spacing': 'off',
|
|
63
|
+
'@typescript-eslint/comma-spacing': 'error',
|
|
64
|
+
|
|
65
|
+
'@typescript-eslint/consistent-type-assertions': [
|
|
66
|
+
'error',
|
|
67
|
+
{
|
|
68
|
+
assertionStyle: 'as',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
|
|
72
|
+
'default-param-last': 'off',
|
|
73
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
74
|
+
|
|
75
|
+
'dot-location': ['warn', 'property'],
|
|
76
|
+
|
|
77
|
+
'eol-last': 'warn',
|
|
78
|
+
|
|
79
|
+
'eqeqeq': 'warn',
|
|
80
|
+
|
|
81
|
+
'@typescript-eslint/explicit-function-return-type': [
|
|
82
|
+
'error',
|
|
83
|
+
{
|
|
84
|
+
allowExpressions: true,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
|
|
88
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
89
|
+
'error',
|
|
90
|
+
{
|
|
91
|
+
overrides: {
|
|
92
|
+
constructors: 'off',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
|
|
97
|
+
'@typescript-eslint/func-call-spacing': 'error',
|
|
98
|
+
|
|
99
|
+
'indent': 'off',
|
|
100
|
+
'@typescript-eslint/indent': [
|
|
101
|
+
'error',
|
|
102
|
+
2,
|
|
103
|
+
{
|
|
104
|
+
SwitchCase: 1,
|
|
105
|
+
MemberExpression: 'off',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
|
|
109
|
+
'jsx-quotes': ['error', 'prefer-single'],
|
|
110
|
+
|
|
111
|
+
'keyword-spacing': 'off',
|
|
112
|
+
'@typescript-eslint/keyword-spacing': 'error',
|
|
113
|
+
|
|
114
|
+
'linebreak-style': ['warn', 'unix'],
|
|
115
|
+
|
|
116
|
+
'lines-between-class-members': 'off',
|
|
117
|
+
'@typescript-eslint/lines-between-class-members': 'warn',
|
|
118
|
+
|
|
119
|
+
'@typescript-eslint/member-delimiter-style': [
|
|
120
|
+
'error',
|
|
121
|
+
{
|
|
122
|
+
multiline: {
|
|
123
|
+
delimiter: 'semi',
|
|
124
|
+
requireLast: true,
|
|
125
|
+
},
|
|
126
|
+
singleline: {
|
|
127
|
+
delimiter: 'comma',
|
|
128
|
+
requireLast: false,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
|
|
133
|
+
'@typescript-eslint/member-ordering': [
|
|
134
|
+
'warn',
|
|
135
|
+
{
|
|
136
|
+
default: [
|
|
137
|
+
// Index signature
|
|
138
|
+
//'signature',
|
|
139
|
+
|
|
140
|
+
// Fields
|
|
141
|
+
'public-abstract-field',
|
|
142
|
+
'protected-abstract-field',
|
|
143
|
+
'private-abstract-field',
|
|
144
|
+
|
|
145
|
+
'public-static-field',
|
|
146
|
+
'protected-static-field',
|
|
147
|
+
'private-static-field',
|
|
148
|
+
|
|
149
|
+
//'public-decorated-field',
|
|
150
|
+
//'protected-decorated-field',
|
|
151
|
+
//'private-decorated-field',
|
|
152
|
+
|
|
153
|
+
'public-instance-field',
|
|
154
|
+
'protected-instance-field',
|
|
155
|
+
'private-instance-field',
|
|
156
|
+
|
|
157
|
+
'public-field',
|
|
158
|
+
'protected-field',
|
|
159
|
+
'private-field',
|
|
160
|
+
|
|
161
|
+
'static-field',
|
|
162
|
+
'instance-field',
|
|
163
|
+
'abstract-field',
|
|
164
|
+
|
|
165
|
+
//'decorated-field',
|
|
166
|
+
|
|
167
|
+
'field',
|
|
168
|
+
|
|
169
|
+
// Constructors
|
|
170
|
+
'public-constructor',
|
|
171
|
+
'protected-constructor',
|
|
172
|
+
'private-constructor',
|
|
173
|
+
|
|
174
|
+
'constructor',
|
|
175
|
+
|
|
176
|
+
// Methods
|
|
177
|
+
'public-abstract-method',
|
|
178
|
+
'public-static-method',
|
|
179
|
+
//'public-decorated-method',
|
|
180
|
+
'public-instance-method',
|
|
181
|
+
'public-method',
|
|
182
|
+
|
|
183
|
+
'protected-abstract-method',
|
|
184
|
+
'protected-static-method',
|
|
185
|
+
//'protected-decorated-method',
|
|
186
|
+
'protected-instance-method',
|
|
187
|
+
'protected-method',
|
|
188
|
+
|
|
189
|
+
'private-abstract-method',
|
|
190
|
+
'private-static-method',
|
|
191
|
+
//'private-decorated-method',
|
|
192
|
+
'private-instance-method',
|
|
193
|
+
'private-method',
|
|
194
|
+
|
|
195
|
+
'abstract-method',
|
|
196
|
+
'static-method',
|
|
197
|
+
//'decorated-method',
|
|
198
|
+
'instance-method',
|
|
199
|
+
|
|
200
|
+
'method',
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
|
|
205
|
+
'@typescript-eslint/method-signature-style': 'warn',
|
|
206
|
+
|
|
207
|
+
'@typescript-eslint/naming-convention': [
|
|
208
|
+
'error',
|
|
209
|
+
{
|
|
210
|
+
selector: ['enum', 'interface', 'class'],
|
|
211
|
+
format: ['PascalCase'],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
selector: 'enumMember',
|
|
215
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
|
|
219
|
+
'no-caller': 'error',
|
|
220
|
+
|
|
221
|
+
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
|
|
222
|
+
|
|
223
|
+
'no-console': 'error',
|
|
224
|
+
|
|
225
|
+
'no-duplicate-imports': 'off',
|
|
226
|
+
'@typescript-eslint/no-duplicate-imports': [
|
|
227
|
+
'error',
|
|
228
|
+
{
|
|
229
|
+
includeExports: true,
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
|
|
233
|
+
'no-eval': 'error',
|
|
234
|
+
|
|
235
|
+
'no-implied-eval': 'off',
|
|
236
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
237
|
+
|
|
238
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
239
|
+
|
|
240
|
+
'no-invalid-this': 'off',
|
|
241
|
+
'@typescript-eslint/no-invalid-this': 'error',
|
|
242
|
+
|
|
243
|
+
'no-label-var': 'warn',
|
|
244
|
+
|
|
245
|
+
'no-loop-func': 'off',
|
|
246
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
247
|
+
|
|
248
|
+
'no-loss-of-precision': 'off',
|
|
249
|
+
'@typescript-eslint/no-loss-of-precision': 'error',
|
|
250
|
+
|
|
251
|
+
'no-mixed-operators': 'warn',
|
|
252
|
+
|
|
253
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
254
|
+
|
|
255
|
+
'@typescript-eslint/no-parameter-properties': 'error',
|
|
256
|
+
|
|
257
|
+
'no-redeclare': 'off',
|
|
258
|
+
'@typescript-eslint/no-redeclare': 'error',
|
|
259
|
+
|
|
260
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
261
|
+
|
|
262
|
+
'no-shadow': 'off',
|
|
263
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
264
|
+
|
|
265
|
+
'@typescript-eslint/no-throw-literal': 'error',
|
|
266
|
+
|
|
267
|
+
'no-trailing-spaces': 'warn',
|
|
268
|
+
|
|
269
|
+
'no-undef-init': 'warn',
|
|
270
|
+
|
|
271
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
|
|
272
|
+
|
|
273
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
|
|
274
|
+
|
|
275
|
+
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
276
|
+
|
|
277
|
+
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
278
|
+
|
|
279
|
+
'no-unused-expressions': 'off',
|
|
280
|
+
'@typescript-eslint/no-unused-expressions': 'warn',
|
|
281
|
+
|
|
282
|
+
'@typescript-eslint/no-unused-vars': [
|
|
283
|
+
'warn',
|
|
284
|
+
{
|
|
285
|
+
ignoreRestSiblings: true,
|
|
286
|
+
argsIgnorePattern: '^_',
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
|
|
290
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
291
|
+
|
|
292
|
+
'no-var': 'error',
|
|
293
|
+
|
|
294
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
|
|
295
|
+
|
|
296
|
+
'object-curly-spacing': 'off',
|
|
297
|
+
'@typescript-eslint/object-curly-spacing': ['warn', 'always'],
|
|
298
|
+
|
|
299
|
+
'@typescript-eslint/prefer-includes': 'warn',
|
|
300
|
+
|
|
301
|
+
'prefer-const': 'error',
|
|
302
|
+
|
|
303
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
|
304
|
+
|
|
305
|
+
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
306
|
+
|
|
307
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
|
|
308
|
+
|
|
309
|
+
'@typescript-eslint/prefer-ts-expect-error': 'warn',
|
|
310
|
+
|
|
311
|
+
'@typescript-eslint/promise-function-async': [
|
|
312
|
+
'error',
|
|
313
|
+
{
|
|
314
|
+
checkArrowFunctions: false,
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
|
|
318
|
+
'quote-props': ['warn', 'as-needed'],
|
|
319
|
+
|
|
320
|
+
'quotes': 'off',
|
|
321
|
+
'@typescript-eslint/quotes': [
|
|
322
|
+
'error',
|
|
323
|
+
'single',
|
|
324
|
+
{
|
|
325
|
+
avoidEscape: true,
|
|
326
|
+
allowTemplateLiterals: true,
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
|
|
330
|
+
'radix': 'warn',
|
|
331
|
+
|
|
332
|
+
'@typescript-eslint/restrict-plus-operands': [
|
|
333
|
+
'error',
|
|
334
|
+
{
|
|
335
|
+
checkCompoundAssignments: true,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
|
|
339
|
+
'no-return-await': 'off',
|
|
340
|
+
'@typescript-eslint/return-await': 'warn',
|
|
341
|
+
|
|
342
|
+
'semi': 'off',
|
|
343
|
+
'@typescript-eslint/semi': [
|
|
344
|
+
'warn',
|
|
345
|
+
'always',
|
|
346
|
+
{
|
|
347
|
+
omitLastInOneLineBlock: false,
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
|
|
351
|
+
'semi-style': 'warn',
|
|
352
|
+
|
|
353
|
+
'sort-imports': [
|
|
354
|
+
'warn',
|
|
355
|
+
{
|
|
356
|
+
ignoreCase: true,
|
|
357
|
+
ignoreDeclarationSort: true,
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
|
|
361
|
+
'space-before-blocks': 'warn',
|
|
362
|
+
|
|
363
|
+
'space-before-function-paren': 'off',
|
|
364
|
+
'@typescript-eslint/space-before-function-paren': 'warn',
|
|
365
|
+
|
|
366
|
+
'space-infix-ops': 'off',
|
|
367
|
+
'@typescript-eslint/space-infix-ops': [
|
|
368
|
+
'error',
|
|
369
|
+
{
|
|
370
|
+
int32Hint: false,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
|
|
374
|
+
'spaced-comment': [
|
|
375
|
+
'warn',
|
|
376
|
+
'always',
|
|
377
|
+
{
|
|
378
|
+
exceptions: ['-', '+', '*'],
|
|
379
|
+
line: {
|
|
380
|
+
markers: ['/'],
|
|
381
|
+
},
|
|
382
|
+
block: {
|
|
383
|
+
balanced: true,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
|
|
388
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
|
|
389
|
+
|
|
390
|
+
'@typescript-eslint/type-annotation-spacing': 'warn',
|
|
391
|
+
|
|
392
|
+
'@typescript-eslint/unified-signatures': 'warn',
|
|
393
|
+
|
|
394
|
+
'yoda': 'warn',
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crycode/eslint-config",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ESLint configuration to be used with TypeScript according to my personal preferences",
|
|
5
|
+
"main": "eslint-config.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"release": "release-script"
|
|
8
|
+
},
|
|
9
|
+
"author": {
|
|
10
|
+
"name": "Peter Müller",
|
|
11
|
+
"email": "peter@crycode.de",
|
|
12
|
+
"url": "https://crycode.de"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"eslint",
|
|
16
|
+
"eslintconfig",
|
|
17
|
+
"typescript"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"files": [
|
|
21
|
+
"eslint-config.js",
|
|
22
|
+
"*.md"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/crycode-de/eslint-config.git"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
|
30
|
+
"@typescript-eslint/parser": "^5.31.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"eslint": "^8.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@alcalzone/release-script": "^3.5.9",
|
|
37
|
+
"@alcalzone/release-script-plugin-license": "^3.5.9",
|
|
38
|
+
"@alcalzone/release-script-plugin-manual-review": "^3.5.9"
|
|
39
|
+
}
|
|
40
|
+
}
|