-
Notifications
You must be signed in to change notification settings - Fork 2
/
@typescript-eslint.js
140 lines (138 loc) · 5.42 KB
/
@typescript-eslint.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
/** @type {import('eslint').Linter.Config} */
const config = {
parser: '@typescript-eslint/parser',
parserOptions: { sourceType: 'module' },
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:prettier/recommended'
],
rules: {
// explicitly (re)enable this as it's disabled by eslint-config-prettier
// and its likely our standard JS config will be used alongside this one
'curly': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/lines-between-class-members': [
'error',
'always',
{ exceptAfterSingleLine: true }
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase', 'PascalCase', 'UPPER_CASE']
},
{ selector: 'property', format: null },
{ selector: 'typeLike', format: ['PascalCase'] },
{
selector: 'typeParameter',
format: ['PascalCase'],
custom: { match: true, regex: /^T([A-Z][a-zA-Z]+)$|^[A-Z]$/u.source }
},
{ selector: 'enumMember', format: ['PascalCase', 'UPPER_CASE'] },
{
selector: 'interface',
format: ['PascalCase'], // disallow "I" prefixing, but allow names like "IAM"
custom: { match: false, regex: /^I[A-Z][a-z]/u.source }
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow'
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['PascalCase', 'camelCase'],
leadingUnderscore: 'require'
},
{
selector: 'memberLike',
modifiers: ['protected'],
format: ['PascalCase', 'camelCase'],
leadingUnderscore: 'require'
},
{
selector: 'memberLike',
modifiers: ['public'],
format: ['PascalCase', 'camelCase'],
leadingUnderscore: 'forbid'
}
],
'@typescript-eslint/no-confusing-void-expression': [
'error',
{ ignoreArrowShorthand: true }
],
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-mixed-enums': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-namespace': [
'off', // todo: need to audit existing codebase to see if declare is fine
{
allowDeclarations: true,
allowDefinitionFiles: true
}
],
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-shadow': 'warn',
'@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true }],
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-use-before-define': [
'error', // Purely stylistic b/c of TS
{ typedefs: false, variables: false }
],
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'warn',
'@typescript-eslint/sort-type-constituents': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/unified-signatures': 'warn', // can be a bit wrong
'array-callback-return': 'off',
'block-scoped-var': 'off',
'camelcase': 'off',
'consistent-return': 'off', // via --noImplicitReturns
'default-param-last': 'off',
'dot-notation': 'off', // @typescript-eslint
'guard-for-in': 'off',
'init-declarations': 'off', // handled by TS & --noImplicitAny
'lines-between-class-members': 'off',
'no-dupe-class-members': 'off', // @typescript-eslint
'no-import-assign': 'off',
'no-invalid-this': 'off', // @typescript-eslint
'no-iterator': 'off',
'no-loop-func': 'off', // @typescript-eslint
'no-proto': 'off', // TS2339
'no-setter-return': 'off', // TS2408
'no-shadow': 'off', // @typescript-eslint
'no-throw-literal': 'off', // @typescript-eslint
'no-underscore-dangle': 'off',
'no-unused-expressions': 'off',
'no-use-before-define': 'off',
'no-useless-constructor': 'off', // @typescript-eslint
'strict': 'off' // via --alwaysStrict
}
};
module.exports = config;