-
Notifications
You must be signed in to change notification settings - Fork 20
/
eslint.config.js
154 lines (144 loc) · 4.36 KB
/
eslint.config.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
// @ts-check
import eslint from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import comments from "eslint-plugin-eslint-comments";
import tseslint from "typescript-eslint";
export default tseslint.config(
{
plugins: {
["@typescript-eslint"]: tseslint.plugin,
["eslint-comments"]: comments,
},
},
// extends
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
// config with just ignores is the replacement for `.eslintignore`
ignores: ["node_modules", "js", "lib"],
},
{
...prettierConfig,
languageOptions: {
globals: {},
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/switch-exhaustiveness-check": [
"error",
{
allowDefaultCaseForExhaustiveSwitch: false,
requireDefaultForNonUnion: true,
},
],
"@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": true,
"ts-check": false,
minimumDescriptionLength: 5,
},
],
"@typescript-eslint/consistent-type-imports": [
"error",
{ prefer: "type-imports", disallowTypeAnnotations: true },
],
"@typescript-eslint/explicit-function-return-type": ["off", { allowIIFEs: true }],
"@typescript-eslint/no-explicit-any": "error",
"no-constant-condition": "error",
"@typescript-eslint/no-unnecessary-condition": [
"error",
{ allowConstantLoopConditions: true },
],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-literal-enum-member": [
"error",
{
allowBitwiseExpressions: true,
},
],
"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
allowBoolean: true,
allowAny: true,
allowNullish: true,
allowRegExp: true,
},
],
"@typescript-eslint/no-unused-expressions": ["error"],
"@typescript-eslint/no-unused-vars": [
"error",
{
caughtErrors: "all",
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{
ignoreConditionalTests: true,
ignorePrimitives: true,
},
],
"object-shorthand": ["error", "always"],
//
// eslint-base
//
curly: ["error", "all"],
eqeqeq: ["error", "always"],
"logical-assignment-operators": "error",
"no-else-return": "error",
// "no-mixed-operators": "error",
"no-console": "error",
"no-process-exit": "error",
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
"one-var": ["error", "never"],
"no-param-reassign": ["error"],
//
// eslint-plugin-eslint-comments
//
// require a eslint-enable comment for every eslint-disable comment
"eslint-comments/disable-enable-pair": [
"error",
{
allowWholeFile: true,
},
],
// disallow a eslint-enable comment for multiple eslint-disable comments
"eslint-comments/no-aggregating-enable": "error",
// disallow duplicate eslint-disable comments
"eslint-comments/no-duplicate-disable": "error",
// disallow eslint-disable comments without rule names
"eslint-comments/no-unlimited-disable": "error",
// disallow unused eslint-disable comments
"eslint-comments/no-unused-disable": "error",
// disallow unused eslint-enable comments
"eslint-comments/no-unused-enable": "error",
// disallow ESLint directive-comments
"eslint-comments/no-use": [
"error",
{
allow: [
"eslint-disable",
"eslint-disable-line",
"eslint-disable-next-line",
"eslint-enable",
"global",
],
},
],
},
},
);