-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
51 lines (42 loc) · 1.56 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
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
plugins: ['@typescript-eslint'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
env: {
node: true,
es2020: true,
},
rules: {
// Enforce explicit function return types
'@typescript-eslint/explicit-function-return-type': 'warn',
// Disallow unused variables
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// Enforce consistent use of type imports
'@typescript-eslint/consistent-type-imports': 'error',
// Enforce naming conventions
'@typescript-eslint/naming-convention': [
'error',
{ selector: 'interface', format: ['PascalCase'], prefix: ['I'] },
{ selector: 'typeAlias', format: ['PascalCase'] },
{ selector: 'enum', format: ['PascalCase'] },
],
// Prefer nullish coalescing
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
// Enforce optional chain syntax
'@typescript-eslint/prefer-optional-chain': 'error',
// Disallow any type
'@typescript-eslint/no-explicit-any': 'warn',
// Enforce consistent type assertions
'@typescript-eslint/consistent-type-assertions': 'error',
// Enforce `includes` method over `indexOf` method
'@typescript-eslint/prefer-includes': 'error',
// Enforce the use of `for-of` loop over the standard `for` loop where possible
'@typescript-eslint/prefer-for-of': 'warn',
},
};