-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.eslintrc.js
234 lines (225 loc) · 7.09 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
const path = require('path')
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module'
},
plugins: [
'sonarjs',
'@typescript-eslint',
'import',
'import-helpers',
'@typescript-eslint/tslint',
'todo-plz',
'jest',
'fp-ts',
'functional'
],
extends: [
'plugin:import/typescript',
'plugin:@typescript-eslint/eslint-recommended',
'prettier',
'prettier/@typescript-eslint',
'plugin:react-hooks/recommended'
],
ignorePatterns: ['node_modules', '**/*.d.ts'],
rules: {
'fp-ts/no-redundant-flow': 'error',
'fp-ts/prefer-traverse': 'error',
'fp-ts/prefer-chain': 'error',
'fp-ts/prefer-bimap': 'error',
'functional/prefer-readonly-type': [
'error',
{
allowLocalMutation: true,
allowMutableReturnType: true,
checkImplicit: false,
ignoreClass: true,
ignoreInterface: false,
ignoreCollections: true
}
],
'sort-imports': [
'warn',
{
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false
}
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/typedef': [
'warn',
{
arrowParameter: false,
memberVariableDeclaration: false,
parameter: false,
propertyDeclaration: true
}
],
'arrow-parens': ['error', 'as-needed'],
'comma-dangle': 'error',
'constructor-super': 'error',
'default-case': 'error',
'dot-notation': 'warn',
'eol-last': 'error',
eqeqeq: ['error', 'smart'],
'func-style': ['warn', 'declaration', { allowArrowFunctions: true }],
'import/no-extraneous-dependencies': [
'warn',
{
devDependencies: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test|mock).[tj]s?(x)']
}
],
'import/no-unresolved': 'error',
'no-bitwise': 'warn',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': [
'warn',
{
allow: ['info', 'error']
}
],
'no-control-regex': 'error',
'no-debugger': 'error',
'no-duplicate-imports': 'warn',
'no-empty': 'warn',
'no-eval': 'error',
'no-fallthrough': [
'error',
{
commentPattern: 'TODO'
}
],
'no-invalid-regexp': 'error',
// "no-invalid-this": "error", // TODO use it instead of tslint after https://github.com/typescript-eslint/typescript-eslint/issues/491
'no-irregular-whitespace': [
'error',
{
skipRegExps: true
}
],
'no-multiple-empty-lines': ['error', { max: 1 }],
'no-new-wrappers': 'error',
'no-regex-spaces': 'error',
'no-restricted-globals': [
'error',
{
name: 'FormData',
message:
"Consider using `import * as FormData from 'isomorphic-form-data'` or `RequestBuilder.multipartFormData` to have proper typechecking"
}
],
'no-restricted-properties': [
2,
{
object: 'jest',
property: 'setTimeout',
message:
"We block overriding default jest test timeout to guarantee that all long ran tests run in a separate category, which usually requires network access. \nIf you need more time for the test please try to split it into several cases, or move it into the 'integration tests' area."
}
],
'no-shadow-restricted-names': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-unused-expressions': ['error', { allowTernary: true }],
'no-unused-labels': 'error',
'no-var': 'error',
'object-curly-spacing': ['error', 'always'],
'prefer-const': 'warn',
curly: 'error',
radix: 'error',
/* sonarjs from tslint*/
'sonarjs/no-all-duplicated-branches': 'warn',
'sonarjs/no-collection-size-mischeck': 'error',
'sonarjs/no-duplicated-branches': 'error',
'sonarjs/no-element-overwrite': 'warn',
'sonarjs/no-identical-conditions': 'error',
'sonarjs/no-identical-expressions': 'error',
'sonarjs/no-redundant-jump': 'error',
'sonarjs/no-unused-collection': 'error',
/* sonarjs from tslint*/
'spaced-comment': 'warn',
'use-isnan': 'error',
'todo-plz/ticket-ref': ['warn', { pattern: '[A-Z]{2}-[0-9]+', terms: ['FIXME'] }],
'jest/no-focused-tests': 'error',
'@typescript-eslint/tslint/config': [
// turn it off for root eslint config, but turn it back in local config
'off',
{
rulesDirectory: [
['@grammarly/tslint-config', 'dist/rules'],
['tslint-eslint-rules', 'dist/rules'],
['tslint-microsoft-contrib'],
['tslint-react', 'rules'],
['tslint-sonarts', 'lib/rules']
].map(args => getRulesDir(...args)),
rules: {
// check mapping of tslint to eslint rules and current status of rules migration here
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md
'function-name': [
true,
{
'method-regex': '^[a-z][\\w\\d]+$',
'private-method-regex': '^__?[a-z][\\w\\d]+$',
'static-method-regex': '^[a-z][\\w\\d]+$',
'function-regex': '^[a-z][\\w\\d]+$'
}
],
/* region sonarts */
// TODO sonarjs will migrate all rules once https://github.com/SonarSource/eslint-plugin-sonarjs/issues/142
'no-accessor-field-mismatch': true,
'no-dead-store': true,
'no-empty-destructuring': true,
'no-gratuitous-expressions': true,
'no-ignored-return': true,
'no-invalid-this': true, // TODO remove after https://github.com/typescript-eslint/typescript-eslint/issues/491
'no-multiline-string-literals': true,
'no-self-assignment': true,
'no-unnecessary-local-variable': true /* microsoft-contrib*/,
'no-unnecessary-override': true /* microsoft-contrib*/,
'no-unthrown-error': true,
'no-useless-increment': true,
'no-variable-usage-before-declaration': true,
/* endregion sonarts */
'promise-must-complete': true /* microsoft-contrib */
}
}
]
},
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname
},
rules: {
// this rule requires type information and therefore requires tsconfig to be resolved via parserOptions
'@typescript-eslint/no-floating-promises': [
'warn',
{
ignoreVoid: true
}
]
},
settings: {
'import/resolver': {
typescript: {
directory: __dirname
}
}
}
}
function getRulesDir(packageName, subDir = '') {
return path.join(path.dirname(require.resolve(packageName)), subDir)
}