@petbee/eslint-config 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -0
- package/package.json +10 -35
- package/rules/best-practices.js +2 -0
- package/rules/typescript.js +289 -288
- package/.eslintrc +0 -3
- package/eslint-config.d.ts +0 -6
- /package/{eslint.config.mjs → index.mjs} +0 -0
package/index.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@petbee/eslint-config",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Petbee's eslint config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"require": "./index.js",
|
|
15
|
-
"import": "./
|
|
15
|
+
"import": "./index.mjs",
|
|
16
|
+
"types": "./index.d.ts"
|
|
16
17
|
},
|
|
17
18
|
"./legacy": "./index.js"
|
|
18
19
|
},
|
|
20
|
+
"types": "index.d.ts",
|
|
19
21
|
"repository": {
|
|
20
22
|
"type": "git",
|
|
21
23
|
"url": "https://github.com/petbee/typescript.git",
|
|
@@ -38,19 +40,19 @@
|
|
|
38
40
|
"url": "https://github.com/petbee/typescript/issues"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"confusing-browser-globals": "^1.0.11"
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
43
|
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
45
44
|
"@typescript-eslint/parser": "^8.32.1",
|
|
46
|
-
"
|
|
45
|
+
"confusing-browser-globals": "^1.0.11",
|
|
47
46
|
"eslint-config-prettier": "^10.1.5",
|
|
48
47
|
"eslint-plugin-cypress": "^4.3.0",
|
|
49
48
|
"eslint-plugin-import": "^2.31.0",
|
|
50
49
|
"eslint-plugin-jest": "^28.11.0",
|
|
51
50
|
"eslint-plugin-n": "^17.18.0",
|
|
52
51
|
"eslint-plugin-prettier": "^5.4.0",
|
|
53
|
-
"eslint-plugin-react": "7.37.5"
|
|
52
|
+
"eslint-plugin-react": "7.37.5"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"eslint": "^9.27.0",
|
|
54
56
|
"prettier": ">=3.0.0",
|
|
55
57
|
"typescript": "^4.0.0 || ^5.0.0"
|
|
56
58
|
},
|
|
@@ -58,33 +60,6 @@
|
|
|
58
60
|
"eslint": {
|
|
59
61
|
"optional": false
|
|
60
62
|
},
|
|
61
|
-
"@typescript-eslint/eslint-plugin": {
|
|
62
|
-
"optional": false
|
|
63
|
-
},
|
|
64
|
-
"@typescript-eslint/parser": {
|
|
65
|
-
"optional": false
|
|
66
|
-
},
|
|
67
|
-
"eslint-config-prettier": {
|
|
68
|
-
"optional": false
|
|
69
|
-
},
|
|
70
|
-
"eslint-plugin-cypress": {
|
|
71
|
-
"optional": false
|
|
72
|
-
},
|
|
73
|
-
"eslint-plugin-import": {
|
|
74
|
-
"optional": false
|
|
75
|
-
},
|
|
76
|
-
"eslint-plugin-jest": {
|
|
77
|
-
"optional": false
|
|
78
|
-
},
|
|
79
|
-
"eslint-plugin-n": {
|
|
80
|
-
"optional": false
|
|
81
|
-
},
|
|
82
|
-
"eslint-plugin-prettier": {
|
|
83
|
-
"optional": false
|
|
84
|
-
},
|
|
85
|
-
"eslint-plugin-react": {
|
|
86
|
-
"optional": false
|
|
87
|
-
},
|
|
88
63
|
"prettier": {
|
|
89
64
|
"optional": false
|
|
90
65
|
},
|
|
@@ -104,5 +79,5 @@
|
|
|
104
79
|
"publishConfig": {
|
|
105
80
|
"access": "public"
|
|
106
81
|
},
|
|
107
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "7f5dd28dc2d4bea8ff05bb8d4fe02c18550bf07c"
|
|
108
83
|
}
|
package/rules/best-practices.js
CHANGED
package/rules/typescript.js
CHANGED
|
@@ -2,303 +2,304 @@ const { hasPackage } = require('../lib/utils')
|
|
|
2
2
|
|
|
3
3
|
const hasTypescript = hasPackage('typescript')
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const tsConfig = [
|
|
6
|
+
{
|
|
7
|
+
files: ['*.ts', '*.tsx'],
|
|
8
|
+
extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended'],
|
|
9
|
+
plugins: ['@typescript-eslint'],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2022,
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
project: [
|
|
15
|
+
// look in the root
|
|
16
|
+
'tsconfig{.eslint.json,.json}',
|
|
17
|
+
// look in dirs like node/react
|
|
18
|
+
'*/tsconfig{.eslint.json,.json}',
|
|
19
|
+
// look in dirs like packages/package/*
|
|
20
|
+
'*/*/tsconfig{.eslint.json,.json}',
|
|
21
|
+
],
|
|
22
|
+
projectFolderIgnoreList: [/node_modules/i],
|
|
23
|
+
// We need this configuration to avoid performance issues in monorepos
|
|
24
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/1192#issuecomment-862414778
|
|
25
|
+
allowAutomaticSingleRunInference: true,
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
//! extensions of native eslint rules
|
|
29
|
+
//! when modifying a rule here, make sure to modify the native one and vice-versa
|
|
30
|
+
|
|
31
|
+
// Don't require a weird naming convention for interfaces
|
|
32
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
33
|
+
|
|
34
|
+
// Disallow declaration of variables already declared in the outer scope
|
|
35
|
+
// https://eslint.org/docs/rules/no-shadow
|
|
36
|
+
'no-shadow': 'off',
|
|
37
|
+
'@typescript-eslint/no-shadow': [
|
|
38
|
+
'error',
|
|
8
39
|
{
|
|
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
|
-
allow: ['arrowFunctions', 'functions', 'methods'],
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
|
|
93
|
-
// Require a consistent naming convention
|
|
94
|
-
// https://typescript-eslint.io/rules/naming-convention/
|
|
95
|
-
camelcase: 'off',
|
|
96
|
-
'@typescript-eslint/naming-convention': [
|
|
97
|
-
'error',
|
|
98
|
-
{
|
|
99
|
-
selector: 'default',
|
|
100
|
-
format: ['camelCase'],
|
|
101
|
-
leadingUnderscore: 'allow',
|
|
102
|
-
trailingUnderscore: 'allow',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
selector: 'variable',
|
|
106
|
-
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
107
|
-
leadingUnderscore: 'allow',
|
|
108
|
-
trailingUnderscore: 'allow',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
selector: 'function',
|
|
112
|
-
format: ['camelCase', 'PascalCase'],
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
selector: 'typeLike',
|
|
116
|
-
format: ['PascalCase'],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
selector: 'memberLike',
|
|
120
|
-
format: null,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
// have to leave this for now as this rule
|
|
124
|
-
// doesn't separate regular parameters from
|
|
125
|
-
// destructured parameters
|
|
126
|
-
selector: 'parameter',
|
|
127
|
-
format: null,
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
|
|
131
|
-
// Disallow use of variables before they are defined
|
|
132
|
-
// https://typescript-eslint.io/rules/no-use-before-define/
|
|
133
|
-
'no-use-before-define': 'off',
|
|
134
|
-
'@typescript-eslint/no-use-before-define': [
|
|
135
|
-
'error',
|
|
136
|
-
{
|
|
137
|
-
functions: false,
|
|
138
|
-
classes: false,
|
|
139
|
-
variables: true,
|
|
140
|
-
enums: false,
|
|
141
|
-
typedefs: false,
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
// ! ts only rules
|
|
145
|
-
// Enforce explicit accessibility modifiers on class properties and methods
|
|
146
|
-
// https://typescript-eslint.io/rules/explicit-member-accessibility/
|
|
147
|
-
'@typescript-eslint/explicit-member-accessibility': [
|
|
148
|
-
'error',
|
|
149
|
-
{
|
|
150
|
-
accessibility: 'explicit',
|
|
151
|
-
overrides: {
|
|
152
|
-
accessors: 'explicit',
|
|
153
|
-
constructors: 'no-public',
|
|
154
|
-
methods: 'explicit',
|
|
155
|
-
parameterProperties: 'explicit',
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
|
|
160
|
-
// Don't allow "any" at all
|
|
161
|
-
// https://typescript-eslint.io/rules/no-explicit-any
|
|
162
|
-
'@typescript-eslint/no-explicit-any': 'error',
|
|
163
|
-
|
|
164
|
-
// Enforce explicit function return type
|
|
165
|
-
// https://typescript-eslint.io/rules/explicit-function-return-type/
|
|
166
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
167
|
-
|
|
168
|
-
// Enforce a consistent way of typing arrays
|
|
169
|
-
// https://typescript-eslint.io/rules/array-type/v
|
|
170
|
-
'@typescript-eslint/array-type': [
|
|
171
|
-
'warn',
|
|
172
|
-
{
|
|
173
|
-
default: 'array-simple',
|
|
174
|
-
readonly: 'array-simple',
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
|
|
178
|
-
// Enforce a consitent way to type objects
|
|
179
|
-
// https://typescript-eslint.io/rules/consistent-type-definitions/
|
|
180
|
-
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
181
|
-
|
|
182
|
-
// Disallow non null assertions (!), comes from the recommended config
|
|
183
|
-
// https://typescript-eslint.io/rules/no-non-null-assertion/
|
|
184
|
-
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
185
|
-
|
|
186
|
-
// Enforce that when adding two variables, operands must both be of type number or of type string
|
|
187
|
-
// https://typescript-eslint.io/rules/restrict-plus-operands/
|
|
188
|
-
'@typescript-eslint/restrict-plus-operands': ['error'],
|
|
189
|
-
|
|
190
|
-
// Enforce optional chaining over chaining AND (&&) operators
|
|
191
|
-
// https://typescript-eslint.io/rules/prefer-optional-chain/
|
|
192
|
-
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
193
|
-
|
|
194
|
-
// Enforce optional chaining over chaining AND (&&) operators
|
|
195
|
-
// https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain/
|
|
196
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
197
|
-
|
|
198
|
-
// Enforce nullish coalescing over short-circuiting
|
|
199
|
-
// https://typescript-eslint.io/rules/prefer-nullish-coalescing/
|
|
200
|
-
'@typescript-eslint/prefer-nullish-coalescing': [
|
|
201
|
-
'warn',
|
|
202
|
-
{
|
|
203
|
-
ignoreConditionalTests: true,
|
|
204
|
-
ignoreMixedLogicalExpressions: true,
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
|
-
|
|
208
|
-
// Prefer usage of as const over literal type
|
|
209
|
-
// https://typescript-eslint.io/rules/prefer-as-const/
|
|
210
|
-
'@typescript-eslint/prefer-as-const': 'error',
|
|
211
|
-
|
|
212
|
-
// Prevent unnecessary type arguments
|
|
213
|
-
// https://typescript-eslint.io/rules/no-unnecessary-type-arguments/
|
|
214
|
-
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
|
|
215
|
-
|
|
216
|
-
// Warns when a namespace qualifier is unnecessary
|
|
217
|
-
// https://typescript-eslint.io/rules/no-unnecessary-qualifier/
|
|
218
|
-
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
|
|
219
|
-
|
|
220
|
-
// Disallow throwing literals as exceptions
|
|
221
|
-
// https://typescript-eslint.io/rules/no-throw-literal/
|
|
222
|
-
'no-throw-literal': 'warn',
|
|
223
|
-
|
|
224
|
-
// Disallows invocation of require() in favor of import statements
|
|
225
|
-
// https://typescript-eslint.io/rules/no-require-imports/
|
|
226
|
-
'@typescript-eslint/no-require-imports': 'warn',
|
|
227
|
-
|
|
228
|
-
// Disallows the use of eval()-like methods
|
|
229
|
-
// https://typescript-eslint.io/rules/no-implied-eval/
|
|
230
|
-
'@typescript-eslint/no-implied-eval': 'error',
|
|
231
|
-
|
|
232
|
-
// Requires Array#sort calls to always provide a compareFunction
|
|
233
|
-
// https://typescript-eslint.io/rules/require-array-sort-compare/
|
|
234
|
-
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
235
|
-
|
|
236
|
-
// Enforce explicit enum item values
|
|
237
|
-
// https://typescript-eslint.io/rules/prefer-enum-initializers/
|
|
238
|
-
'@typescript-eslint/prefer-enum-initializers': 'warn',
|
|
239
|
-
|
|
240
|
-
// Explicitly defines what a module scoped method returns
|
|
241
|
-
// https://typescript-eslint.io/rules/explicit-module-boundary-types/
|
|
242
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
243
|
-
|
|
244
|
-
// Disallow // @ts comments
|
|
245
|
-
// https://typescript-eslint.io/rules/ban-ts-comment/
|
|
246
|
-
'@typescript-eslint/ban-ts-comment': [
|
|
247
|
-
'error',
|
|
248
|
-
{
|
|
249
|
-
'ts-expect-error': 'allow-with-description',
|
|
250
|
-
'ts-ignore': true,
|
|
251
|
-
'ts-nocheck': true,
|
|
252
|
-
'ts-check': false,
|
|
253
|
-
minimumDescriptionLength: 3,
|
|
254
|
-
},
|
|
255
|
-
],
|
|
256
|
-
|
|
257
|
-
// Disallows unnecessary constraints on generic types
|
|
258
|
-
// https://typescript-eslint.io/rules/no-unnecessary-type-constraint/
|
|
259
|
-
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
|
|
260
|
-
|
|
261
|
-
// Enforces consistent usage of type imports
|
|
262
|
-
// https://typescript-eslint.io/rules/consistent-type-imports/
|
|
263
|
-
'@typescript-eslint/consistent-type-imports': [
|
|
264
|
-
'warn',
|
|
265
|
-
{
|
|
266
|
-
prefer: 'type-imports',
|
|
267
|
-
disallowTypeAnnotations: false,
|
|
268
|
-
},
|
|
269
|
-
],
|
|
270
|
-
},
|
|
40
|
+
allow: ['done', 'next', 'resolve', 'reject', 'cb'],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
// Prevent unused declared variables
|
|
45
|
+
// https://typescript-eslint.io/rules/no-unused-vars/
|
|
46
|
+
'no-unused-vars': 'off',
|
|
47
|
+
'@typescript-eslint/no-unused-vars': [
|
|
48
|
+
'warn',
|
|
49
|
+
{
|
|
50
|
+
ignoreRestSiblings: true,
|
|
51
|
+
argsIgnorePattern: '^_+',
|
|
52
|
+
varsIgnorePattern: '^_',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
|
|
56
|
+
// Disallows the use of eval()-like methods
|
|
57
|
+
// https://typescript-eslint.io/rules/no-magic-numbers/
|
|
58
|
+
'no-magic-numbers': 'off',
|
|
59
|
+
'@typescript-eslint/no-magic-numbers': [
|
|
60
|
+
'off',
|
|
61
|
+
{
|
|
62
|
+
ignore: [0, 1, 2, 3],
|
|
63
|
+
ignoreArrayIndexes: true,
|
|
64
|
+
enforceConst: true,
|
|
65
|
+
detectObjects: false,
|
|
66
|
+
ignoreNumericLiteralTypes: true,
|
|
67
|
+
ignoreEnums: true,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
// Enforce parameters with default values to be last
|
|
72
|
+
// https://typescript-eslint.io/rules/default-param-last/
|
|
73
|
+
'default-param-last': 'off',
|
|
74
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
75
|
+
|
|
76
|
+
// Disallow useless constructors
|
|
77
|
+
// https://typescript-eslint.io/rules/no-useless-constructor/
|
|
78
|
+
'no-useless-constructor': 'off',
|
|
79
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
80
|
+
|
|
81
|
+
// Disallow empty functions, except for standalone funcs/arrows
|
|
82
|
+
// https://eslint.org/docs/rules/no-empty-function
|
|
83
|
+
'no-empty-function': 'off',
|
|
84
|
+
'@typescript-eslint/no-empty-function': [
|
|
85
|
+
'error',
|
|
86
|
+
{
|
|
87
|
+
allow: ['arrowFunctions', 'functions', 'methods'],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
|
|
91
|
+
// Require a consistent naming convention
|
|
92
|
+
// https://typescript-eslint.io/rules/naming-convention/
|
|
93
|
+
camelcase: 'off',
|
|
94
|
+
'@typescript-eslint/naming-convention': [
|
|
95
|
+
'error',
|
|
96
|
+
{
|
|
97
|
+
selector: 'default',
|
|
98
|
+
format: ['camelCase'],
|
|
99
|
+
leadingUnderscore: 'allow',
|
|
100
|
+
trailingUnderscore: 'allow',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
selector: 'variable',
|
|
104
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
105
|
+
leadingUnderscore: 'allow',
|
|
106
|
+
trailingUnderscore: 'allow',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
selector: 'function',
|
|
110
|
+
format: ['camelCase', 'PascalCase'],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
selector: 'typeLike',
|
|
114
|
+
format: ['PascalCase'],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
selector: 'memberLike',
|
|
118
|
+
format: null,
|
|
271
119
|
},
|
|
272
120
|
{
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
121
|
+
// have to leave this for now as this rule
|
|
122
|
+
// doesn't separate regular parameters from
|
|
123
|
+
// destructured parameters
|
|
124
|
+
selector: 'parameter',
|
|
125
|
+
format: null,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
|
|
129
|
+
// Disallow use of variables before they are defined
|
|
130
|
+
// https://typescript-eslint.io/rules/no-use-before-define/
|
|
131
|
+
'no-use-before-define': 'off',
|
|
132
|
+
'@typescript-eslint/no-use-before-define': [
|
|
133
|
+
'error',
|
|
134
|
+
{
|
|
135
|
+
functions: false,
|
|
136
|
+
classes: false,
|
|
137
|
+
variables: true,
|
|
138
|
+
enums: false,
|
|
139
|
+
typedefs: false,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
// ! ts only rules
|
|
143
|
+
// Enforce explicit accessibility modifiers on class properties and methods
|
|
144
|
+
// https://typescript-eslint.io/rules/explicit-member-accessibility/
|
|
145
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
146
|
+
'error',
|
|
147
|
+
{
|
|
148
|
+
accessibility: 'explicit',
|
|
149
|
+
overrides: {
|
|
150
|
+
accessors: 'explicit',
|
|
151
|
+
constructors: 'no-public',
|
|
152
|
+
methods: 'explicit',
|
|
153
|
+
parameterProperties: 'explicit',
|
|
278
154
|
},
|
|
279
155
|
},
|
|
280
156
|
],
|
|
157
|
+
|
|
158
|
+
// Don't allow "any" at all
|
|
159
|
+
// https://typescript-eslint.io/rules/no-explicit-any
|
|
160
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
161
|
+
|
|
162
|
+
// Enforce explicit function return type
|
|
163
|
+
// https://typescript-eslint.io/rules/explicit-function-return-type/
|
|
164
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
165
|
+
|
|
166
|
+
// Enforce a consistent way of typing arrays
|
|
167
|
+
// https://typescript-eslint.io/rules/array-type/v
|
|
168
|
+
'@typescript-eslint/array-type': [
|
|
169
|
+
'warn',
|
|
170
|
+
{
|
|
171
|
+
default: 'array-simple',
|
|
172
|
+
readonly: 'array-simple',
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
|
|
176
|
+
// Enforce a consitent way to type objects
|
|
177
|
+
// https://typescript-eslint.io/rules/consistent-type-definitions/
|
|
178
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
179
|
+
|
|
180
|
+
// Disallow non null assertions (!), comes from the recommended config
|
|
181
|
+
// https://typescript-eslint.io/rules/no-non-null-assertion/
|
|
182
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
183
|
+
|
|
184
|
+
// Enforce that when adding two variables, operands must both be of type number or of type string
|
|
185
|
+
// https://typescript-eslint.io/rules/restrict-plus-operands/
|
|
186
|
+
'@typescript-eslint/restrict-plus-operands': ['error'],
|
|
187
|
+
|
|
188
|
+
// Enforce optional chaining over chaining AND (&&) operators
|
|
189
|
+
// https://typescript-eslint.io/rules/prefer-optional-chain/
|
|
190
|
+
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
191
|
+
|
|
192
|
+
// Enforce optional chaining over chaining AND (&&) operators
|
|
193
|
+
// https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain/
|
|
194
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
195
|
+
|
|
196
|
+
// Enforce nullish coalescing over short-circuiting
|
|
197
|
+
// https://typescript-eslint.io/rules/prefer-nullish-coalescing/
|
|
198
|
+
'@typescript-eslint/prefer-nullish-coalescing': [
|
|
199
|
+
'warn',
|
|
200
|
+
{
|
|
201
|
+
ignoreConditionalTests: true,
|
|
202
|
+
ignoreMixedLogicalExpressions: true,
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
|
|
206
|
+
// Prefer usage of as const over literal type
|
|
207
|
+
// https://typescript-eslint.io/rules/prefer-as-const/
|
|
208
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
209
|
+
|
|
210
|
+
// Prevent unnecessary type arguments
|
|
211
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-arguments/
|
|
212
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
|
|
213
|
+
|
|
214
|
+
// Warns when a namespace qualifier is unnecessary
|
|
215
|
+
// https://typescript-eslint.io/rules/no-unnecessary-qualifier/
|
|
216
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
|
|
217
|
+
|
|
218
|
+
// Disallow throwing literals as exceptions
|
|
219
|
+
// https://typescript-eslint.io/rules/no-throw-literal/
|
|
220
|
+
'no-throw-literal': 'warn',
|
|
221
|
+
|
|
222
|
+
// Disallows invocation of require() in favor of import statements
|
|
223
|
+
// https://typescript-eslint.io/rules/no-require-imports/
|
|
224
|
+
'@typescript-eslint/no-require-imports': 'warn',
|
|
225
|
+
|
|
226
|
+
// Disallows the use of eval()-like methods
|
|
227
|
+
// https://typescript-eslint.io/rules/no-implied-eval/
|
|
228
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
229
|
+
|
|
230
|
+
// Requires Array#sort calls to always provide a compareFunction
|
|
231
|
+
// https://typescript-eslint.io/rules/require-array-sort-compare/
|
|
232
|
+
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
233
|
+
|
|
234
|
+
// Enforce explicit enum item values
|
|
235
|
+
// https://typescript-eslint.io/rules/prefer-enum-initializers/
|
|
236
|
+
'@typescript-eslint/prefer-enum-initializers': 'warn',
|
|
237
|
+
|
|
238
|
+
// Explicitly defines what a module scoped method returns
|
|
239
|
+
// https://typescript-eslint.io/rules/explicit-module-boundary-types/
|
|
240
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
241
|
+
|
|
242
|
+
// Disallow // @ts comments
|
|
243
|
+
// https://typescript-eslint.io/rules/ban-ts-comment/
|
|
244
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
245
|
+
'error',
|
|
246
|
+
{
|
|
247
|
+
'ts-expect-error': 'allow-with-description',
|
|
248
|
+
'ts-ignore': true,
|
|
249
|
+
'ts-nocheck': true,
|
|
250
|
+
'ts-check': false,
|
|
251
|
+
minimumDescriptionLength: 3,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
|
|
255
|
+
// Disallows unnecessary constraints on generic types
|
|
256
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-constraint/
|
|
257
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
|
|
258
|
+
|
|
259
|
+
// Enforces consistent usage of type imports
|
|
260
|
+
// https://typescript-eslint.io/rules/consistent-type-imports/
|
|
261
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
262
|
+
'warn',
|
|
263
|
+
{
|
|
264
|
+
prefer: 'type-imports',
|
|
265
|
+
disallowTypeAnnotations: false,
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
files: ['*.d.ts'],
|
|
272
|
+
rules: {
|
|
273
|
+
'import/order': 'off',
|
|
274
|
+
'import/no-duplicates': 'off',
|
|
275
|
+
'import/export': 'off',
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
]
|
|
279
|
+
|
|
280
|
+
module.exports = hasTypescript
|
|
281
|
+
? {
|
|
282
|
+
overrides: tsConfig,
|
|
281
283
|
}
|
|
282
284
|
: {}
|
|
283
285
|
|
|
284
286
|
// Flat config for ESLint v9 (no extends, plugins as object)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
287
|
+
module.exports.flat = hasTypescript
|
|
288
|
+
? [
|
|
289
|
+
{
|
|
290
|
+
files: tsConfig[0].files,
|
|
291
|
+
languageOptions: {
|
|
292
|
+
parser: require('@typescript-eslint/parser'),
|
|
293
|
+
parserOptions: tsConfig[0].parserOptions,
|
|
294
|
+
},
|
|
295
|
+
plugins: {
|
|
296
|
+
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
|
|
297
|
+
},
|
|
298
|
+
rules: tsConfig[0].rules,
|
|
293
299
|
},
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
{
|
|
301
|
+
files: tsConfig[1].files,
|
|
302
|
+
rules: tsConfig[1].rules,
|
|
296
303
|
},
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
{
|
|
300
|
-
files: overrides[1]?.files,
|
|
301
|
-
rules: overrides[1]?.rules,
|
|
302
|
-
},
|
|
303
|
-
]
|
|
304
|
-
}
|
|
304
|
+
]
|
|
305
|
+
: []
|
package/.eslintrc
DELETED
package/eslint-config.d.ts
DELETED
|
File without changes
|