forked from CodingSans/eslint-config-codingsans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypescript-recommended.js
118 lines (114 loc) · 3.5 KB
/
typescript-recommended.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
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: '.',
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
'prettier/prettier': [
'error',
{
bracketSpacing: true,
trailingComma: 'all',
singleQuote: true,
semi: true,
useTabs: false,
tabWidth: 2,
printWidth: 120,
},
],
eqeqeq: 'error',
curly: 'error',
'no-trailing-spaces': 'error',
'eol-last': ['error', 'always'],
'prefer-template': 'error',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/array-type': ['error', { array: true }],
'@typescript-eslint/explicit-module-boundary-types': [
'warn',
{
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: true,
shouldTrackReferences: true,
},
],
'@typescript-eslint/naming-convention': [
'warn',
{ selector: 'default', format: ['camelCase'] },
{ selector: 'variableLike', format: ['camelCase'] },
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'parameter',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
{ selector: 'enumMember', format: ['UPPER_CASE'] },
{ selector: 'memberLike', format: ['camelCase', 'PascalCase', 'UPPER_CASE'] },
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{ selector: 'typeParameter', format: ['PascalCase'], prefix: ['T'] },
{
selector: 'typeLike',
format: ['PascalCase'],
custom: { regex: '^[IT][A-Z]', match: false },
},
{
selector: 'interface',
format: ['PascalCase'],
custom: { regex: '^[IT][A-Z]', match: false },
},
],
'@typescript-eslint/restrict-template-expressions': [
'warn',
{
allowNumber: true,
allowBoolean: false,
allowAny: false,
allowNullish: false,
},
],
'@typescript-eslint/prefer-optional-chain': ['warn'],
'@typescript-eslint/prefer-ts-expect-error': ['error'],
'@typescript-eslint/promise-function-async': ['warn'],
'@typescript-eslint/prefer-string-starts-ends-with': ['error'],
'@typescript-eslint/prefer-reduce-type-parameter': ['warn'],
'@typescript-eslint/prefer-includes': ['error'],
'@typescript-eslint/prefer-for-of': ['error'],
'@typescript-eslint/prefer-enum-initializers': ['warn'],
'@typescript-eslint/no-loop-func': ['warn'],
},
};