@jimmy.codes/eslint-config 6.0.0 → 6.1.0
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/dist/astro-CqgWkoKy.js +63 -0
- package/dist/constants-dep165g5.js +73 -0
- package/dist/has-dependency-B3Fi8OzA.js +42 -0
- package/dist/index.d.ts +7299 -9884
- package/dist/index.js +448 -558
- package/dist/interop-default-D4l3hsYQ.js +17 -0
- package/dist/jest-CzZHXxA7.js +62 -0
- package/dist/nextjs-Bh8fqE_o.js +24 -0
- package/dist/playwright-CHYoYi52.js +41 -0
- package/dist/react-BE1N8MTt.js +92 -0
- package/dist/storybook-BO4plVPp.js +32 -0
- package/dist/tanstack-query-DF8OWtLq.js +24 -0
- package/dist/testing-library-XmNQWB2F.js +31 -0
- package/dist/typescript-fvBsWGqo.js +62 -0
- package/dist/upwarn-C7t3ub-R.js +16 -0
- package/dist/vitest-J--7DiIk.js +74 -0
- package/package.json +8 -8
- package/dist/astro-NEJ73UBN.js +0 -71
- package/dist/chunk-72FT76PY.js +0 -9
- package/dist/chunk-7RIW3P47.js +0 -55
- package/dist/chunk-BDIXPIKB.js +0 -12
- package/dist/chunk-XMM6FHXC.js +0 -82
- package/dist/jest-SCRGNX6Z.js +0 -80
- package/dist/nextjs-CRRBTFXP.js +0 -36
- package/dist/playwright-2HMMFF3D.js +0 -50
- package/dist/react-IAR3MTFF.js +0 -126
- package/dist/storybook-XHFO7L4T.js +0 -38
- package/dist/tanstack-query-MM3M2QJO.js +0 -35
- package/dist/testing-library-QHZMYCZH.js +0 -43
- package/dist/typescript-PLNEW3M4.js +0 -86
- package/dist/vitest-IAENZQ7B.js +0 -92
package/dist/index.js
CHANGED
|
@@ -1,607 +1,497 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
hasJest,
|
|
4
|
-
hasNext,
|
|
5
|
-
hasPlaywright,
|
|
6
|
-
hasReact,
|
|
7
|
-
hasReactQuery,
|
|
8
|
-
hasStorybook,
|
|
9
|
-
hasTestingLibrary,
|
|
10
|
-
hasTypescript,
|
|
11
|
-
hasVitest
|
|
12
|
-
} from "./chunk-7RIW3P47.js";
|
|
13
|
-
import {
|
|
14
|
-
GLOB_CJS,
|
|
15
|
-
GLOB_IGNORES,
|
|
16
|
-
GLOB_TESTS
|
|
17
|
-
} from "./chunk-XMM6FHXC.js";
|
|
18
|
-
|
|
19
|
-
// src/configs/commonjs.ts
|
|
1
|
+
import { GLOB_CJS, GLOB_IGNORES, GLOB_TESTS } from "./constants-dep165g5.js";
|
|
2
|
+
import { hasAstro, hasJest, hasNext, hasPlaywright, hasReact, hasReactQuery, hasStorybook, hasTestingLibrary, hasTypescript, hasVitest } from "./has-dependency-B3Fi8OzA.js";
|
|
20
3
|
import globals from "globals";
|
|
21
|
-
var commonjsConfig = () => {
|
|
22
|
-
return [
|
|
23
|
-
{
|
|
24
|
-
files: [GLOB_CJS],
|
|
25
|
-
languageOptions: {
|
|
26
|
-
globals: globals.commonjs
|
|
27
|
-
},
|
|
28
|
-
name: "jimmy.codes/commonjs"
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// src/configs/eslint-comments.ts
|
|
34
|
-
import comments2 from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
35
|
-
|
|
36
|
-
// src/rules/eslint-comments.ts
|
|
37
4
|
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
5
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
6
|
+
import { configs, importX } from "eslint-plugin-import-x";
|
|
7
|
+
import nodePlugin from "eslint-plugin-n";
|
|
8
|
+
import eslint from "@eslint/js";
|
|
9
|
+
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
10
|
+
import perfectionist from "eslint-plugin-perfectionist";
|
|
11
|
+
import eslintConfigPrettier from "eslint-config-prettier/flat";
|
|
12
|
+
import * as regexpPlugin from "eslint-plugin-regexp";
|
|
13
|
+
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
14
|
+
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
15
|
+
|
|
16
|
+
//#region src/configs/commonjs.ts
|
|
17
|
+
const commonjsConfig = () => {
|
|
18
|
+
return [{
|
|
19
|
+
files: [GLOB_CJS],
|
|
20
|
+
languageOptions: { globals: globals.commonjs },
|
|
21
|
+
name: "jimmy.codes/commonjs"
|
|
22
|
+
}];
|
|
42
23
|
};
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
rules: eslintCommentsRules
|
|
51
|
-
}
|
|
52
|
-
];
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/rules/eslint-comments.ts
|
|
27
|
+
const eslintCommentsRules = {
|
|
28
|
+
...comments.recommended.rules,
|
|
29
|
+
"@eslint-community/eslint-comments/no-unused-disable": "off",
|
|
30
|
+
"@eslint-community/eslint-comments/require-description": "error"
|
|
53
31
|
};
|
|
54
32
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/configs/eslint-comments.ts
|
|
35
|
+
const eslintCommentsConfig = () => {
|
|
36
|
+
return [{
|
|
37
|
+
...comments.recommended,
|
|
38
|
+
name: "jimmy.codes/eslint-comments",
|
|
39
|
+
rules: eslintCommentsRules
|
|
40
|
+
}];
|
|
63
41
|
};
|
|
64
42
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/configs/ignores.ts
|
|
45
|
+
const ignoresConfig = (ignores) => {
|
|
46
|
+
return [{
|
|
47
|
+
ignores: [...GLOB_IGNORES, ...ignores],
|
|
48
|
+
name: "jimmy.codes/ignores"
|
|
49
|
+
}];
|
|
50
|
+
};
|
|
69
51
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/rules/imports.ts
|
|
54
|
+
const importsRules = {
|
|
55
|
+
...configs.recommended.rules,
|
|
56
|
+
"import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
57
|
+
"import-x/extensions": [
|
|
58
|
+
"error",
|
|
59
|
+
"never",
|
|
60
|
+
{
|
|
61
|
+
checkTypedImports: true,
|
|
62
|
+
svg: "always"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"import-x/first": "error",
|
|
66
|
+
"import-x/namespace": "off",
|
|
67
|
+
"import-x/newline-after-import": "error",
|
|
68
|
+
"import-x/no-absolute-path": "error",
|
|
69
|
+
"import-x/no-duplicates": "error",
|
|
70
|
+
"import-x/no-empty-named-blocks": "error",
|
|
71
|
+
"import-x/no-named-as-default": "error",
|
|
72
|
+
"import-x/no-named-as-default-member": "error",
|
|
73
|
+
"import-x/no-self-import": "error",
|
|
74
|
+
"import-x/no-unresolved": ["error", { ignore: [String.raw`\.svg$`] }],
|
|
75
|
+
"import-x/no-useless-path-segments": "error"
|
|
92
76
|
};
|
|
93
77
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
];
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/configs/imports.ts
|
|
80
|
+
const importsTypescriptConfig = () => {
|
|
81
|
+
const { rules, settings } = configs.typescript;
|
|
82
|
+
return [{
|
|
83
|
+
name: "jimmy.codes/imports/typescript",
|
|
84
|
+
rules,
|
|
85
|
+
settings: {
|
|
86
|
+
"import-x/extensions": settings["import-x/extensions"],
|
|
87
|
+
"import-x/external-module-folders": settings["import-x/external-module-folders"],
|
|
88
|
+
"import-x/parsers": settings["import-x/parsers"],
|
|
89
|
+
"import-x/resolver-next": [createTypeScriptImportResolver()]
|
|
90
|
+
}
|
|
91
|
+
}];
|
|
109
92
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
rules: importsRules
|
|
121
|
-
},
|
|
122
|
-
...isTypescriptEnabled ? importsTypescriptConfig() : []
|
|
123
|
-
];
|
|
93
|
+
const importsConfig = ({ isTypescriptEnabled = false } = {}) => {
|
|
94
|
+
return [{
|
|
95
|
+
name: "jimmy.codes/imports",
|
|
96
|
+
plugins: {
|
|
97
|
+
"import-x": importX,
|
|
98
|
+
"n": nodePlugin
|
|
99
|
+
},
|
|
100
|
+
rules: importsRules
|
|
101
|
+
}, ...isTypescriptEnabled ? importsTypescriptConfig() : []];
|
|
124
102
|
};
|
|
125
103
|
|
|
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
|
-
// Disallows unnecessary computed keys in objects (e.g., `{["key"]: value}` instead of `{ key: value }`)
|
|
188
|
-
"no-useless-constructor": "error",
|
|
189
|
-
// Disallows empty constructors
|
|
190
|
-
"no-useless-rename": "error",
|
|
191
|
-
// Disallows renaming variables to the same name in import/export/destructuring
|
|
192
|
-
"no-useless-return": "error",
|
|
193
|
-
// Prevents redundant `return;` statements
|
|
194
|
-
"no-var": "error",
|
|
195
|
-
// Enforce `let` and `const` (modern best practice)
|
|
196
|
-
"object-shorthand": "error",
|
|
197
|
-
// Enforces `{ foo }` instead of `{ foo: foo }`
|
|
198
|
-
"prefer-arrow-callback": "error",
|
|
199
|
-
// Enforces arrow functions in callbacks where possible
|
|
200
|
-
"prefer-const": "error",
|
|
201
|
-
// Requires `const` when a variable isn’t reassigned
|
|
202
|
-
"prefer-destructuring": [
|
|
203
|
-
"error",
|
|
204
|
-
{
|
|
205
|
-
AssignmentExpression: {
|
|
206
|
-
array: false,
|
|
207
|
-
// Allow `x = arr[0]`, don't force `[x] = arr`
|
|
208
|
-
object: false
|
|
209
|
-
// Allow `x = obj.x`, don't force `{ x } = obj`
|
|
210
|
-
},
|
|
211
|
-
VariableDeclarator: {
|
|
212
|
-
array: false,
|
|
213
|
-
object: true
|
|
214
|
-
// Enforce destructuring for objects (`const { x } = obj`)
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
],
|
|
218
|
-
"prefer-object-spread": "error",
|
|
219
|
-
// Enforces `{ ...obj }` over `Object.assign()`
|
|
220
|
-
"prefer-rest-params": "error",
|
|
221
|
-
// Use `...args` instead of `arguments`
|
|
222
|
-
"prefer-spread": "error",
|
|
223
|
-
// Use `[...arr]` instead of `arr.concat()`
|
|
224
|
-
"prefer-template": "error",
|
|
225
|
-
// Use template literals instead of string concatenation
|
|
226
|
-
"radix": "error",
|
|
227
|
-
// Require a radix argument in `parseInt`
|
|
228
|
-
"require-await": "error",
|
|
229
|
-
// Disallows async functions without `await` (prevents unnecessary `async`)
|
|
230
|
-
"strict": ["error", "safe"],
|
|
231
|
-
// Enforces `"use strict"` only where needed (safe mode)
|
|
232
|
-
"symbol-description": "error"
|
|
233
|
-
// Requires descriptions when creating `Symbol()`
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/rules/javascript.ts
|
|
106
|
+
const additionalRules = {
|
|
107
|
+
"array-callback-return": ["error", { allowImplicit: true }],
|
|
108
|
+
"arrow-body-style": ["error", "always"],
|
|
109
|
+
"class-methods-use-this": "error",
|
|
110
|
+
"consistent-return": "error",
|
|
111
|
+
"curly": ["error", "all"],
|
|
112
|
+
"default-case": "error",
|
|
113
|
+
"default-case-last": "error",
|
|
114
|
+
"no-console": "warn",
|
|
115
|
+
"no-implicit-coercion": "error",
|
|
116
|
+
"no-implicit-globals": "error",
|
|
117
|
+
"no-loop-func": "error",
|
|
118
|
+
"no-magic-numbers": ["error", { ignore: [
|
|
119
|
+
0,
|
|
120
|
+
1,
|
|
121
|
+
-1,
|
|
122
|
+
2
|
|
123
|
+
] }],
|
|
124
|
+
"no-new-wrappers": "error",
|
|
125
|
+
"no-param-reassign": ["error", { props: true }],
|
|
126
|
+
"no-promise-executor-return": "error",
|
|
127
|
+
"no-self-compare": "error",
|
|
128
|
+
"no-template-curly-in-string": "error",
|
|
129
|
+
"no-throw-literal": "error",
|
|
130
|
+
"no-unassigned-vars": "error",
|
|
131
|
+
"no-unmodified-loop-condition": "error",
|
|
132
|
+
"no-unreachable-loop": "error",
|
|
133
|
+
"no-use-before-define": ["error", {
|
|
134
|
+
allowNamedExports: false,
|
|
135
|
+
classes: false,
|
|
136
|
+
functions: true,
|
|
137
|
+
variables: true
|
|
138
|
+
}],
|
|
139
|
+
"no-useless-computed-key": "error",
|
|
140
|
+
"no-useless-constructor": "error",
|
|
141
|
+
"no-useless-rename": "error",
|
|
142
|
+
"no-useless-return": "error",
|
|
143
|
+
"no-var": "error",
|
|
144
|
+
"object-shorthand": "error",
|
|
145
|
+
"prefer-arrow-callback": "error",
|
|
146
|
+
"prefer-const": "error",
|
|
147
|
+
"prefer-destructuring": ["error", {
|
|
148
|
+
AssignmentExpression: {
|
|
149
|
+
array: false,
|
|
150
|
+
object: false
|
|
151
|
+
},
|
|
152
|
+
VariableDeclarator: {
|
|
153
|
+
array: false,
|
|
154
|
+
object: true
|
|
155
|
+
}
|
|
156
|
+
}],
|
|
157
|
+
"prefer-object-spread": "error",
|
|
158
|
+
"prefer-rest-params": "error",
|
|
159
|
+
"prefer-spread": "error",
|
|
160
|
+
"prefer-template": "error",
|
|
161
|
+
"radix": "error",
|
|
162
|
+
"require-await": "error",
|
|
163
|
+
"strict": ["error", "safe"],
|
|
164
|
+
"symbol-description": "error"
|
|
234
165
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
166
|
+
const javascriptRules = {
|
|
167
|
+
...eslint.configs.recommended.rules,
|
|
168
|
+
...additionalRules
|
|
238
169
|
};
|
|
239
170
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
name: "jimmy.codes/javascript/testing",
|
|
253
|
-
rules: {
|
|
254
|
-
"no-magic-numbers": "off"
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
];
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/configs/javascript.ts
|
|
173
|
+
const javascriptConfig = () => {
|
|
174
|
+
return [{
|
|
175
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
176
|
+
name: "jimmy.codes/javascript",
|
|
177
|
+
rules: javascriptRules
|
|
178
|
+
}, {
|
|
179
|
+
files: GLOB_TESTS,
|
|
180
|
+
name: "jimmy.codes/javascript/testing",
|
|
181
|
+
rules: { "no-magic-numbers": "off" }
|
|
182
|
+
}];
|
|
258
183
|
};
|
|
259
184
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
{
|
|
278
|
-
applyToEndTag: false,
|
|
279
|
-
// No need for a blank line before closing JSDoc
|
|
280
|
-
startLines: 1
|
|
281
|
-
// Require exactly one blank line before the first tag
|
|
282
|
-
}
|
|
283
|
-
]
|
|
284
|
-
};
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/rules/jsdoc.ts
|
|
187
|
+
const jsdocRules = () => {
|
|
188
|
+
return {
|
|
189
|
+
...jsdocPlugin.configs["flat/recommended-typescript-error"].rules,
|
|
190
|
+
"jsdoc/require-jsdoc": "off",
|
|
191
|
+
"jsdoc/require-param": "off",
|
|
192
|
+
"jsdoc/require-returns": "off",
|
|
193
|
+
"jsdoc/tag-lines": [
|
|
194
|
+
"error",
|
|
195
|
+
"always",
|
|
196
|
+
{
|
|
197
|
+
applyToEndTag: false,
|
|
198
|
+
startLines: 1
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
};
|
|
285
202
|
};
|
|
286
203
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
];
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/configs/jsdoc.ts
|
|
206
|
+
const jsdocConfig = () => {
|
|
207
|
+
return [{
|
|
208
|
+
...jsdocPlugin.configs["flat/recommended-typescript-error"],
|
|
209
|
+
name: "jimmy.codes/jsdoc",
|
|
210
|
+
rules: jsdocRules()
|
|
211
|
+
}];
|
|
296
212
|
};
|
|
297
213
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
"n/prefer-global/console": ["error", "always"],
|
|
312
|
-
"n/prefer-node-protocol": "error",
|
|
313
|
-
"n/process-exit-as-throw": "error"
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/rules/node.ts
|
|
216
|
+
const nodeRules = {
|
|
217
|
+
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
218
|
+
"n/no-deprecated-api": "error",
|
|
219
|
+
"n/no-exports-assign": "error",
|
|
220
|
+
"n/no-new-require": "error",
|
|
221
|
+
"n/no-path-concat": "error",
|
|
222
|
+
"n/no-process-exit": "off",
|
|
223
|
+
"n/no-top-level-await": ["error", { ignoreBin: true }],
|
|
224
|
+
"n/prefer-global/console": ["error", "always"],
|
|
225
|
+
"n/prefer-node-protocol": "error",
|
|
226
|
+
"n/process-exit-as-throw": "error"
|
|
314
227
|
};
|
|
315
228
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
rules: nodeRules
|
|
325
|
-
}
|
|
326
|
-
];
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/configs/node.ts
|
|
231
|
+
const nodeConfig = () => {
|
|
232
|
+
return [{
|
|
233
|
+
name: "jimmy.codes/node",
|
|
234
|
+
plugins: { n: nodePlugin },
|
|
235
|
+
rules: nodeRules
|
|
236
|
+
}];
|
|
327
237
|
};
|
|
328
238
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
// "declare-enum",
|
|
366
|
-
// "enum",
|
|
367
|
-
// "export-enum",
|
|
368
|
-
// ["declare-interface", "declare-type"],
|
|
369
|
-
// ["interface", "type"],
|
|
370
|
-
// ["export-interface", "export-type"],
|
|
371
|
-
// "declare-class",
|
|
372
|
-
// "class",
|
|
373
|
-
// "export-class",
|
|
374
|
-
// "declare-function",
|
|
375
|
-
// "function",
|
|
376
|
-
// "export-function",
|
|
377
|
-
// ],
|
|
378
|
-
// ignoreCase: true,
|
|
379
|
-
// newlinesBetween: "ignore",
|
|
380
|
-
// order: "asc",
|
|
381
|
-
// partitionByComment: false,
|
|
382
|
-
// partitionByNewLine: false,
|
|
383
|
-
// specialCharacters: "keep",
|
|
384
|
-
// type: "natural",
|
|
385
|
-
// },
|
|
386
|
-
// ],
|
|
387
|
-
"perfectionist/sort-modules": "off"
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/rules/perfectionist.ts
|
|
241
|
+
const perfectionistRules = {
|
|
242
|
+
...perfectionist.configs["recommended-natural"].rules,
|
|
243
|
+
"perfectionist/sort-imports": ["error", {
|
|
244
|
+
customGroups: {
|
|
245
|
+
type: {},
|
|
246
|
+
value: {}
|
|
247
|
+
},
|
|
248
|
+
environment: "node",
|
|
249
|
+
groups: [
|
|
250
|
+
"side-effect-style",
|
|
251
|
+
"builtin",
|
|
252
|
+
"type",
|
|
253
|
+
"external",
|
|
254
|
+
"internal-type",
|
|
255
|
+
"internal",
|
|
256
|
+
[
|
|
257
|
+
"parent-type",
|
|
258
|
+
"sibling-type",
|
|
259
|
+
"index-type"
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
"parent",
|
|
263
|
+
"sibling",
|
|
264
|
+
"index"
|
|
265
|
+
],
|
|
266
|
+
"object",
|
|
267
|
+
"style",
|
|
268
|
+
"unknown"
|
|
269
|
+
],
|
|
270
|
+
internalPattern: ["^~/.*", "^@/.*"],
|
|
271
|
+
order: "asc",
|
|
272
|
+
type: "natural"
|
|
273
|
+
}],
|
|
274
|
+
"perfectionist/sort-modules": "off"
|
|
388
275
|
};
|
|
389
276
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
rules: perfectionistRules
|
|
399
|
-
}
|
|
400
|
-
];
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/configs/perfectionist.ts
|
|
279
|
+
const perfectionistConfig = () => {
|
|
280
|
+
return [{
|
|
281
|
+
name: "jimmy.codes/perfectionist",
|
|
282
|
+
plugins: { perfectionist },
|
|
283
|
+
rules: perfectionistRules
|
|
284
|
+
}];
|
|
401
285
|
};
|
|
402
286
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/configs/prettier.ts
|
|
289
|
+
const prettierConfig = () => {
|
|
290
|
+
return [{
|
|
291
|
+
...eslintConfigPrettier,
|
|
292
|
+
name: "jimmy.codes/prettier"
|
|
293
|
+
}];
|
|
409
294
|
};
|
|
410
295
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
"regexp/no-potentially-useless-backreference": "error",
|
|
422
|
-
"regexp/no-useless-flag": "error",
|
|
423
|
-
"regexp/optimal-lookaround-quantifier": "error"
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/rules/regexp.ts
|
|
298
|
+
const regexpRules = {
|
|
299
|
+
...regexpPlugin.configs["flat/recommended"].rules,
|
|
300
|
+
"regexp/confusing-quantifier": "error",
|
|
301
|
+
"regexp/no-empty-alternative": "error",
|
|
302
|
+
"regexp/no-lazy-ends": "error",
|
|
303
|
+
"regexp/no-potentially-useless-backreference": "error",
|
|
304
|
+
"regexp/no-useless-flag": "error",
|
|
305
|
+
"regexp/optimal-lookaround-quantifier": "error"
|
|
424
306
|
};
|
|
425
307
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
];
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/configs/regexp.ts
|
|
310
|
+
const regexpConfig = () => {
|
|
311
|
+
return [{
|
|
312
|
+
name: "jimmy.codes/regexp",
|
|
313
|
+
plugins: { regexp: regexpPlugin },
|
|
314
|
+
rules: regexpRules
|
|
315
|
+
}];
|
|
435
316
|
};
|
|
436
317
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/rules/stylistic.ts
|
|
320
|
+
const stylisticRules = {
|
|
321
|
+
"@stylistic/jsx-curly-brace-presence": ["error", "never"],
|
|
322
|
+
"@stylistic/object-curly-newline": ["error", {
|
|
323
|
+
consistent: true,
|
|
324
|
+
multiline: true
|
|
325
|
+
}],
|
|
326
|
+
"@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
327
|
+
"@stylistic/padding-line-between-statements": [
|
|
328
|
+
"error",
|
|
329
|
+
{
|
|
330
|
+
blankLine: "always",
|
|
331
|
+
next: "return",
|
|
332
|
+
prev: "*"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
blankLine: "always",
|
|
336
|
+
next: "*",
|
|
337
|
+
prev: [
|
|
338
|
+
"const",
|
|
339
|
+
"let",
|
|
340
|
+
"var"
|
|
341
|
+
]
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
blankLine: "any",
|
|
345
|
+
next: [
|
|
346
|
+
"const",
|
|
347
|
+
"let",
|
|
348
|
+
"var"
|
|
349
|
+
],
|
|
350
|
+
prev: [
|
|
351
|
+
"const",
|
|
352
|
+
"let",
|
|
353
|
+
"var"
|
|
354
|
+
]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
blankLine: "always",
|
|
358
|
+
next: "*",
|
|
359
|
+
prev: "directive"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
blankLine: "any",
|
|
363
|
+
next: "directive",
|
|
364
|
+
prev: "directive"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
blankLine: "always",
|
|
368
|
+
next: "function",
|
|
369
|
+
prev: "*"
|
|
370
|
+
}
|
|
371
|
+
]
|
|
487
372
|
};
|
|
488
373
|
|
|
489
|
-
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/configs/stylistic.ts
|
|
490
376
|
function stylisticConfig() {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
},
|
|
497
|
-
rules: stylisticRules
|
|
498
|
-
}
|
|
499
|
-
];
|
|
377
|
+
return [{
|
|
378
|
+
name: "jimmy.codes/stylistic",
|
|
379
|
+
plugins: { "@stylistic": stylisticPlugin },
|
|
380
|
+
rules: stylisticRules
|
|
381
|
+
}];
|
|
500
382
|
}
|
|
501
383
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
"unicorn/no-process-exit": "off",
|
|
518
|
-
"unicorn/no-useless-undefined": "off",
|
|
519
|
-
"unicorn/prefer-node-protocol": "off",
|
|
520
|
-
"unicorn/prevent-abbreviations": "off"
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/rules/unicorn.ts
|
|
386
|
+
const unicornRules = {
|
|
387
|
+
...eslintPluginUnicorn.configs.recommended.rules,
|
|
388
|
+
"unicorn/filename-case": "off",
|
|
389
|
+
"unicorn/import-style": "off",
|
|
390
|
+
"unicorn/no-abusive-eslint-disable": "off",
|
|
391
|
+
"unicorn/no-anonymous-default-export": "off",
|
|
392
|
+
"unicorn/no-array-callback-reference": "off",
|
|
393
|
+
"unicorn/no-array-reduce": "off",
|
|
394
|
+
"unicorn/no-null": "off",
|
|
395
|
+
"unicorn/no-process-exit": "off",
|
|
396
|
+
"unicorn/no-useless-undefined": "off",
|
|
397
|
+
"unicorn/prefer-node-protocol": "off",
|
|
398
|
+
"unicorn/prevent-abbreviations": "off"
|
|
521
399
|
};
|
|
522
400
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
];
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/configs/unicorn.ts
|
|
403
|
+
const unicornConfig = () => {
|
|
404
|
+
return [{
|
|
405
|
+
...eslintPluginUnicorn.configs.recommended,
|
|
406
|
+
name: "jimmy.codes/unicorn",
|
|
407
|
+
rules: unicornRules
|
|
408
|
+
}];
|
|
532
409
|
};
|
|
533
410
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/utils/unwrap.ts
|
|
413
|
+
/**
|
|
414
|
+
* Unwraps an imported module, resolving its `default` export if it's a function.
|
|
415
|
+
*
|
|
416
|
+
* This is useful for handling ESLint configurations and other dynamically imported modules,
|
|
417
|
+
* ensuring compatibility with both named and default exports.
|
|
418
|
+
*
|
|
419
|
+
* @template T - The imported module type.
|
|
420
|
+
*
|
|
421
|
+
* @param module - A dynamically imported module.
|
|
422
|
+
*
|
|
423
|
+
* @returns
|
|
424
|
+
* If the module has a `default` export that is a function, it returns the result of calling it.
|
|
425
|
+
* Otherwise, it returns the module itself.
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* const config = await unwrap(import("./configs/react"));
|
|
429
|
+
*/
|
|
430
|
+
const unwrap = async (module) => {
|
|
431
|
+
const resolved = await module;
|
|
432
|
+
if (typeof resolved.default === "function") return resolved.default();
|
|
433
|
+
return resolved;
|
|
541
434
|
};
|
|
542
435
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
overrides,
|
|
602
|
-
moreOverrides
|
|
603
|
-
].flat();
|
|
604
|
-
};
|
|
605
|
-
export {
|
|
606
|
-
defineConfig
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/factory.ts
|
|
438
|
+
/**
|
|
439
|
+
* Generates an ESLint configuration based on the provided options.
|
|
440
|
+
*
|
|
441
|
+
* @returns The resolved ESLint configuration.
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* import { defineConfig } from "@jimmy.codes/eslint-config";
|
|
445
|
+
*
|
|
446
|
+
* export default defineConfig();
|
|
447
|
+
*/
|
|
448
|
+
const defineConfig = async ({ astro = false, autoDetect = true, ignores = [], jest = false, nextjs = false, overrides = [], playwright = false, react = false, storybook = false, tanstackQuery = false, testingLibrary = false, typescript = false, vitest = false } = {}, ...moreOverrides) => {
|
|
449
|
+
const getFlag = (explicit, detector) => {
|
|
450
|
+
return explicit || autoDetect && detector();
|
|
451
|
+
};
|
|
452
|
+
const isTypescriptEnabled = getFlag(typescript, hasTypescript);
|
|
453
|
+
const isReactEnabled = getFlag(react, hasReact);
|
|
454
|
+
const isAstroEnabled = getFlag(astro, hasAstro);
|
|
455
|
+
const isTanstackQueryEnabled = getFlag(tanstackQuery, hasReactQuery);
|
|
456
|
+
const isTestingLibraryEnabled = getFlag(testingLibrary, hasTestingLibrary);
|
|
457
|
+
const isPlaywrightEnabled = getFlag(playwright, hasPlaywright);
|
|
458
|
+
const isStorybookEnabled = getFlag(storybook, hasStorybook);
|
|
459
|
+
const isNextjsEnabled = getFlag(nextjs, hasNext);
|
|
460
|
+
const isJestEnabled = getFlag(jest, hasJest);
|
|
461
|
+
const isVitestEnabled = getFlag(vitest, hasVitest);
|
|
462
|
+
const baseConfigs = [
|
|
463
|
+
javascriptConfig(),
|
|
464
|
+
perfectionistConfig(),
|
|
465
|
+
nodeConfig(),
|
|
466
|
+
unicornConfig(),
|
|
467
|
+
eslintCommentsConfig(),
|
|
468
|
+
regexpConfig(),
|
|
469
|
+
jsdocConfig(),
|
|
470
|
+
importsConfig({ isTypescriptEnabled }),
|
|
471
|
+
stylisticConfig()
|
|
472
|
+
];
|
|
473
|
+
const featureConfigs = await Promise.all([
|
|
474
|
+
isTypescriptEnabled && unwrap(import("./typescript-fvBsWGqo.js")),
|
|
475
|
+
isReactEnabled && unwrap(import("./react-BE1N8MTt.js")),
|
|
476
|
+
isTanstackQueryEnabled && unwrap(import("./tanstack-query-DF8OWtLq.js")),
|
|
477
|
+
isAstroEnabled && unwrap(import("./astro-CqgWkoKy.js")),
|
|
478
|
+
isJestEnabled && unwrap(import("./jest-CzZHXxA7.js")),
|
|
479
|
+
isVitestEnabled && unwrap(import("./vitest-J--7DiIk.js")),
|
|
480
|
+
isTestingLibraryEnabled && unwrap(import("./testing-library-XmNQWB2F.js")),
|
|
481
|
+
isPlaywrightEnabled && unwrap(import("./playwright-CHYoYi52.js")),
|
|
482
|
+
isStorybookEnabled && unwrap(import("./storybook-BO4plVPp.js")),
|
|
483
|
+
isNextjsEnabled && unwrap(import("./nextjs-Bh8fqE_o.js"))
|
|
484
|
+
]);
|
|
485
|
+
return [
|
|
486
|
+
...baseConfigs,
|
|
487
|
+
...featureConfigs.filter(Boolean),
|
|
488
|
+
commonjsConfig(),
|
|
489
|
+
ignoresConfig(ignores),
|
|
490
|
+
prettierConfig(),
|
|
491
|
+
overrides,
|
|
492
|
+
moreOverrides
|
|
493
|
+
].flat();
|
|
607
494
|
};
|
|
495
|
+
|
|
496
|
+
//#endregion
|
|
497
|
+
export { defineConfig };
|