forked from 2004Scape/Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
101 lines (96 loc) · 3.25 KB
/
.eslintrc.cjs
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
/**
* TODO: Use flat config file as eslintrc is deprecated.
* https://eslint.org/docs/latest/use/configure/configuration-files
*/
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script'
}
},
{
files: ['src/**/*.test.ts'],
extends: ['plugin:vitest/legacy-recommended'],
plugins: ['vitest'],
rules: {
'vitest/no-focused-tests': 'error',
'vitest/no-disabled-tests': 'warn',
'vitest/consistent-test-it': 'warn',
'vitest/require-top-level-describe': [
'error',
{
'maxNumberOfTopLevelDescribes': 1
}
]
}
}
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'unused-imports'],
rules: {
indent: ['error', 4, { SwitchCase: 1 }],
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],
/**
* https://eslint.org/docs/latest/rules/no-constant-condition#checkloops
*
* Allows constant conditions in loops but not in if statements
*/
'no-constant-condition': ['error', { checkLoops: false }],
/**
* (jkm) this rule is included in the default ruleset, we should consider
* resolving the issues and setting it to error
* https://eslint.org/docs/latest/rules/no-case-declarations
*/
'no-case-declarations': 'warn',
/**
* (jkm)
* The following rules are included in @typescript-eslint/recommended
* I have set them to warn instead of error, to avoid having to fix them
* We should consider fixing them and setting them to error
*/
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
/**
* https://eslint.org/docs/latest/rules/no-unused-vars
*/
'@typescript-eslint/no-unused-vars': [
// TODO: Set to error
'warn',
{
/**
* Allow variables prefixed with underscores to skip this rule.
* There aren't many good reasons to have unused variables,
* but the codebase has 100s of them.
*/
'vars': 'all',
'varsIgnorePattern': '^_',
/**
* Allow parameters prefixed with underscores to skip this rule.
* This is a common practice for router methods with req and res parameters.
*/
'args': 'all',
'argsIgnorePattern': '^_',
}
],
/**
* https://github.com/sweepline/eslint-plugin-unused-imports
*/
'unused-imports/no-unused-imports': 'error',
}
};