-
Notifications
You must be signed in to change notification settings - Fork 62
/
.eslintrc.js
196 lines (196 loc) · 6.62 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
module.exports = {
root: true,
ignorePatterns: ['**/*'],
plugins: ['@nx', 'unicorn', 'unused-imports', 'prettier'],
overrides: [
{
files: ['*.ts', '*.js'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [
{
sourceTag: 'frontend',
bannedExternalImports: ['@nestjs/common', '@prisma/client']
},
{
sourceTag: 'backend',
bannedExternalImports: ['@angular/core']
},
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*']
}
]
}
]
}
},
{
files: ['*.ts'],
extends: [
'plugin:@nx/typescript',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:unicorn/recommended',
'prettier'
],
parserOptions: {
project: 'tsconfig.base.json'
},
rules: {
quotes: [
'error',
'single',
{
avoidEscape: true
}
],
'no-var': ['error'],
'prefer-const': ['error'],
'no-empty': [
'error',
{
allowEmptyCatch: true
}
],
eqeqeq: ['error', 'smart'],
'@typescript-eslint/no-empty-function': [
'error',
{
// Arrow functions: () => {} is identical to () => void 0, but
// easier to understand.
// Ctors: Private empty ctors are often useful for classes with
// async static method to create instances that want to mark their
// ctor as private.
allow: ['arrowFunctions', 'constructors']
}
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
types: ['boolean', 'string', 'number'],
modifiers: ['global'],
format: ['UPPER_CASE']
},
{
selector: 'variable',
types: ['boolean', 'string', 'number'],
modifiers: ['exported'],
format: ['strictCamelCase', 'UPPER_CASE', 'PascalCase']
},
{
selector: 'class',
format: ['PascalCase']
},
{
selector: 'enumMember',
format: ['UPPER_CASE']
},
{
selector: 'typeParameter',
format: ['PascalCase']
},
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: false
}
}
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
varsIgnorePattern: '^_',
argsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-inferrable-types': [
'warn',
{ ignoreParameters: true }
],
// TypeScript's type narrowing isn't infallible, quite common to have
// cases of this, I don't find the warning helpful, better to bring
// up in review.
'@typescript-eslint/no-non-null-assertion': ['off'],
// Way too sensitive. Most cases it catches are silly, and bad naming is
// easy to flag in review.
'unicorn/prevent-abbreviations': ['off'],
// Not going to make devs use obscure JS syntax for something so minor.
'unicorn/numeric-separators-style': [
'warn',
{ onlyIfContainsSeparator: true }
],
// Removing `null` entirely is a noble intention, but reality is that
// many libraries use it explicitly, especially Prisma. Plus, it's an
// further thing for new devs to learn about. Better to flag bad uses in
// review, where the distinction can be explained.
'unicorn/no-null': ['off'],
// Backend is still on CJS.
'unicorn/prefer-module': ['off'],
// Because of above.
'unicorn/prefer-top-level-await': ['off'],
// Horrible for rethrowing errors
'unicorn/prefer-ternary': ['off'],
// Better parity with other langauges, we use `1 << 0` frequently next
// to other shifts when defining bit fields.
'unicorn/prefer-math-trunc': ['off'],
// Why???
'unicorn/switch-case-braces': ['off'],
// Overly strong, often clearer to handle some error first.
'unicorn/no-negated-condition': ['off'],
// Sometimes we want things like `mockResolvedValue(undefined)` in
// tests. Rule below this handles the actually bad cases.
'unicorn/no-useless-undefined': ['off'],
// Some frontend unit tests are like this currently.
'unicorn/no-empty-file': ['off'],
'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
// Abusable, but fine in some cases. Prefer to handle in review.
'unicorn/no-array-callback-reference': ['off'],
// A class may still wish to extend a class with only static members.
'unicorn/no-static-only-class': ['off'],
// Methods scoped inside each other is often far better for readability
// of a class.
'unicorn/consistent-function-scoping': ['off'],
// Usually for-const-of is preferred but forEach is sometimes far more
// readable, often identical performance on V8.
'unicorn/no-array-for-each': ['off'],
// JS switches look terrible, hurts readability.
'unicorn/prefer-switch': ['off'],
// What the hell is wrong with .flat(2)
'unicorn/no-magic-array-flat-depth': ['off'],
// Stupid CJS/ESM complaints, don't care.
'unicorn/import-style': ['off']
}
},
{
files: ['*.spec.ts', '*.spec.js', '*.e2e-spec.ts'],
env: { jest: true },
rules: {
// Sometimes we want things like `mockResolvedValue(undefined)` in
// tests. Rule below this handles the actually bad cases.
'unicorn/no-useless-undefined': ['off'],
'no-undef-init': ['error'],
eqeqeq: ['off']
}
},
{
files: ['*.js'],
extends: ['plugin:@nx/javascript'],
rules: {}
}
]
};