@jimmy.codes/eslint-config 6.0.0 → 6.2.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/index.js CHANGED
@@ -1,607 +1,497 @@
1
- import {
2
- hasAstro,
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
- var eslintCommentsRules = {
39
- ...comments.recommended.rules,
40
- "@eslint-community/eslint-comments/no-unused-disable": "off",
41
- "@eslint-community/eslint-comments/require-description": "error"
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
- // src/configs/eslint-comments.ts
45
- var eslintCommentsConfig = () => {
46
- return [
47
- {
48
- ...comments2.recommended,
49
- name: "jimmy.codes/eslint-comments",
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
- // src/configs/ignores.ts
56
- var ignoresConfig = (ignores) => {
57
- return [
58
- {
59
- ignores: [...GLOB_IGNORES, ...ignores],
60
- name: "jimmy.codes/ignores"
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
- // src/configs/imports.ts
66
- import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
67
- import { configs as configs2, importX } from "eslint-plugin-import-x";
68
- import nodePlugin from "eslint-plugin-n";
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
- // src/rules/imports.ts
71
- import { configs } from "eslint-plugin-import-x";
72
- var importsRules = {
73
- ...configs.recommended.rules,
74
- "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
75
- "import-x/extensions": [
76
- "error",
77
- "never",
78
- { checkTypedImports: true, svg: "always" }
79
- ],
80
- "import-x/first": "error",
81
- // ! can't get this rule to work
82
- "import-x/namespace": "off",
83
- "import-x/newline-after-import": "error",
84
- "import-x/no-absolute-path": "error",
85
- "import-x/no-duplicates": "error",
86
- "import-x/no-empty-named-blocks": "error",
87
- "import-x/no-named-as-default": "error",
88
- "import-x/no-named-as-default-member": "error",
89
- "import-x/no-self-import": "error",
90
- "import-x/no-unresolved": ["error", { ignore: [String.raw`\.svg$`] }],
91
- "import-x/no-useless-path-segments": "error"
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
- // src/configs/imports.ts
95
- var importsTypescriptConfig = () => {
96
- const { rules, settings } = configs2.typescript;
97
- return [
98
- {
99
- name: "jimmy.codes/imports/typescript",
100
- rules,
101
- settings: {
102
- "import-x/extensions": settings["import-x/extensions"],
103
- "import-x/external-module-folders": settings["import-x/external-module-folders"],
104
- "import-x/parsers": settings["import-x/parsers"],
105
- "import-x/resolver-next": [createTypeScriptImportResolver()]
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
- var importsConfig = ({
111
- isTypescriptEnabled = false
112
- } = {}) => {
113
- return [
114
- {
115
- name: "jimmy.codes/imports",
116
- plugins: {
117
- "import-x": importX,
118
- "n": nodePlugin
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
- // src/rules/javascript.ts
127
- import eslint from "@eslint/js";
128
- var additionalRules = {
129
- "array-callback-return": [
130
- "error",
131
- {
132
- allowImplicit: true
133
- // Allow implicit return for flexibility while enforcing return consistency
134
- }
135
- ],
136
- "arrow-body-style": ["error", "always"],
137
- // Enforce `{}` in arrow functions for consistency (open to revisiting)
138
- "class-methods-use-this": "error",
139
- // Ensures class methods are used within their class (avoids unnecessary methods)
140
- "consistent-return": "error",
141
- // Prevents inconsistent function returns (e.g., sometimes returning `undefined`)
142
- "curly": ["error", "all"],
143
- // Enforce `{}` around all control statements (avoids accidental bugs)
144
- "default-case": "error",
145
- // Require `default` case in switch statements (prevents unintended fallthrough)
146
- "default-case-last": "error",
147
- // Ensure the `default` case is the last one in `switch`
148
- "no-console": "warn",
149
- // Allow logging in development, but should be reviewed for production builds
150
- "no-implicit-coercion": "error",
151
- // Prevents shorthand type conversions (e.g., `!!value`, `+var`)
152
- "no-implicit-globals": "error",
153
- // Prevents defining variables in the global scope
154
- "no-loop-func": "error",
155
- // Disallow function declarations inside loops (prevents scoping issues)
156
- "no-magic-numbers": ["error", { ignore: [0, 1, -1, 2] }],
157
- // Helps catch unexplained numbers while allowing common values
158
- "no-new-wrappers": "error",
159
- // Prevents `new String()`, `new Number()`, etc. (use literals instead)
160
- "no-param-reassign": ["error", { props: true }],
161
- // Disallow reassigning function parameters but allow modifying object properties
162
- "no-promise-executor-return": "error",
163
- // Ensures `new Promise` executors always return something
164
- "no-self-compare": "error",
165
- // Disallows `x === x` (usually a mistake)
166
- "no-template-curly-in-string": "error",
167
- // Flags unintended use of `${}` inside strings without backticks
168
- "no-throw-literal": "error",
169
- // Prevents throwing non-error objects (e.g., `throw "error"` should be `throw new Error("error")`)
170
- "no-unassigned-vars": "error",
171
- // Disallow let or var variables that are read but never assigned
172
- "no-unmodified-loop-condition": "error",
173
- // Ensures loop conditions change, preventing infinite loops
174
- "no-unreachable-loop": "error",
175
- // Prevents loops that can never execute
176
- "no-use-before-define": [
177
- "error",
178
- {
179
- allowNamedExports: false,
180
- classes: false,
181
- functions: true,
182
- // Allow function hoisting
183
- variables: true
184
- }
185
- ],
186
- "no-useless-computed-key": "error",
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
- var javascriptRules = {
236
- ...eslint.configs.recommended.rules,
237
- ...additionalRules
166
+ const javascriptRules = {
167
+ ...eslint.configs.recommended.rules,
168
+ ...additionalRules
238
169
  };
239
170
 
240
- // src/configs/javascript.ts
241
- var javascriptConfig = () => {
242
- return [
243
- {
244
- linterOptions: {
245
- reportUnusedDisableDirectives: true
246
- },
247
- name: "jimmy.codes/javascript",
248
- rules: javascriptRules
249
- },
250
- {
251
- files: GLOB_TESTS,
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
- // src/configs/jsdoc.ts
261
- import jsdocPlugin2 from "eslint-plugin-jsdoc";
262
-
263
- // src/rules/jsdoc.ts
264
- import jsdocPlugin from "eslint-plugin-jsdoc";
265
- var jsdocRules = () => {
266
- return {
267
- ...jsdocPlugin.configs["flat/recommended-typescript-error"].rules,
268
- "jsdoc/require-jsdoc": "off",
269
- // Disable enforced JSDoc (TypeScript provides type info)
270
- "jsdoc/require-param": "off",
271
- // Avoid redundant param documentation (rely on TypeScript)
272
- "jsdoc/require-returns": "off",
273
- // Avoid redundant return type documentation (rely on TypeScript)
274
- "jsdoc/tag-lines": [
275
- "error",
276
- "always",
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
- // src/configs/jsdoc.ts
288
- var jsdocConfig = () => {
289
- return [
290
- {
291
- ...jsdocPlugin2.configs["flat/recommended-typescript-error"],
292
- name: "jimmy.codes/jsdoc",
293
- rules: jsdocRules()
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
- // src/configs/node.ts
299
- import nodePlugin2 from "eslint-plugin-n";
300
-
301
- // src/rules/node.ts
302
- var nodeRules = {
303
- "n/handle-callback-err": ["error", "^(err|error)$"],
304
- "n/no-deprecated-api": "error",
305
- "n/no-exports-assign": "error",
306
- "n/no-new-require": "error",
307
- "n/no-path-concat": "error",
308
- "n/no-process-exit": "off",
309
- // TODO [2025-12-31]: enable this rule
310
- "n/no-top-level-await": ["error", { ignoreBin: true }],
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
- // src/configs/node.ts
317
- var nodeConfig = () => {
318
- return [
319
- {
320
- name: "jimmy.codes/node",
321
- plugins: {
322
- n: nodePlugin2
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
- // src/configs/perfectionist.ts
330
- import perfectionist2 from "eslint-plugin-perfectionist";
331
-
332
- // src/rules/perfectionist.ts
333
- import perfectionist from "eslint-plugin-perfectionist";
334
- var perfectionistRules = {
335
- ...perfectionist.configs["recommended-natural"].rules,
336
- "perfectionist/sort-imports": [
337
- "error",
338
- {
339
- customGroups: { type: {}, value: {} },
340
- environment: "node",
341
- groups: [
342
- "side-effect-style",
343
- "builtin",
344
- "type",
345
- "external",
346
- "internal-type",
347
- "internal",
348
- ["parent-type", "sibling-type", "index-type"],
349
- ["parent", "sibling", "index"],
350
- "object",
351
- "style",
352
- "unknown"
353
- ],
354
- internalPattern: ["^~/.*", "^@/.*"],
355
- order: "asc",
356
- type: "natural"
357
- }
358
- ],
359
- // TODO: enable perfectionist/sort-modules
360
- // "perfectionist/sort-modules": [
361
- // "error",
362
- // {
363
- // customGroups: [],
364
- // groups: [
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
- // src/configs/perfectionist.ts
391
- var perfectionistConfig = () => {
392
- return [
393
- {
394
- name: "jimmy.codes/perfectionist",
395
- plugins: {
396
- perfectionist: perfectionist2
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
- // src/configs/prettier.ts
404
- import eslintConfigPrettier from "eslint-config-prettier/flat";
405
- var prettierConfig = () => {
406
- return [
407
- { ...eslintConfigPrettier, name: "jimmy.codes/prettier" }
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
- // src/configs/regexp.ts
412
- import * as regexpPlugin2 from "eslint-plugin-regexp";
413
-
414
- // src/rules/regexp.ts
415
- import * as regexpPlugin from "eslint-plugin-regexp";
416
- var regexpRules = {
417
- ...regexpPlugin.configs["flat/recommended"].rules,
418
- "regexp/confusing-quantifier": "error",
419
- "regexp/no-empty-alternative": "error",
420
- "regexp/no-lazy-ends": "error",
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
- // src/configs/regexp.ts
427
- var regexpConfig = () => {
428
- return [
429
- {
430
- name: "jimmy.codes/regexp",
431
- plugins: { regexp: regexpPlugin2 },
432
- rules: regexpRules
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
- // src/configs/stylistic.ts
438
- import stylisticPlugin from "@stylistic/eslint-plugin";
439
-
440
- // src/rules/stylistic.ts
441
- var stylisticRules = {
442
- "@stylistic/jsx-curly-brace-presence": ["error", "never"],
443
- "@stylistic/object-curly-newline": [
444
- "error",
445
- {
446
- consistent: true,
447
- multiline: true
448
- }
449
- ],
450
- "@stylistic/object-property-newline": [
451
- "error",
452
- { allowAllPropertiesOnSameLine: true }
453
- ],
454
- "@stylistic/padding-line-between-statements": [
455
- "error",
456
- {
457
- blankLine: "always",
458
- next: "return",
459
- prev: "*"
460
- },
461
- {
462
- blankLine: "always",
463
- next: "*",
464
- prev: ["const", "let", "var"]
465
- },
466
- {
467
- blankLine: "any",
468
- next: ["const", "let", "var"],
469
- prev: ["const", "let", "var"]
470
- },
471
- {
472
- blankLine: "always",
473
- next: "*",
474
- prev: "directive"
475
- },
476
- {
477
- blankLine: "any",
478
- next: "directive",
479
- prev: "directive"
480
- },
481
- {
482
- blankLine: "always",
483
- next: "function",
484
- prev: "*"
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
- // src/configs/stylistic.ts
374
+ //#endregion
375
+ //#region src/configs/stylistic.ts
490
376
  function stylisticConfig() {
491
- return [
492
- {
493
- name: "jimmy.codes/stylistic",
494
- plugins: {
495
- "@stylistic": stylisticPlugin
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
- // src/configs/unicorn.ts
503
- import eslintPluginUnicorn2 from "eslint-plugin-unicorn";
504
-
505
- // src/rules/unicorn.ts
506
- import eslintPluginUnicorn from "eslint-plugin-unicorn";
507
- var unicornRules = {
508
- ...eslintPluginUnicorn.configs.recommended.rules,
509
- "unicorn/filename-case": "off",
510
- "unicorn/import-style": "off",
511
- "unicorn/no-abusive-eslint-disable": "off",
512
- "unicorn/no-anonymous-default-export": "off",
513
- "unicorn/no-array-callback-reference": "off",
514
- // TODO: enable when https://github.com/sindresorhus/eslint-plugin-unicorn/issues/781 is resolved.
515
- "unicorn/no-array-reduce": "off",
516
- "unicorn/no-null": "off",
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
- // src/configs/unicorn.ts
524
- var unicornConfig = () => {
525
- return [
526
- {
527
- ...eslintPluginUnicorn2.configs.recommended,
528
- name: "jimmy.codes/unicorn",
529
- rules: unicornRules
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
- // src/utils/unwrap.ts
535
- var unwrap = async (module) => {
536
- const resolved = await module;
537
- if (typeof resolved.default === "function") {
538
- return resolved.default();
539
- }
540
- return resolved;
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
- // src/factory.ts
544
- var defineConfig = async ({
545
- astro = false,
546
- autoDetect = true,
547
- ignores = [],
548
- jest = false,
549
- nextjs = false,
550
- overrides = [],
551
- playwright = false,
552
- react = false,
553
- storybook = false,
554
- tanstackQuery = false,
555
- testingLibrary = false,
556
- typescript = false,
557
- vitest = false
558
- } = {}, ...moreOverrides) => {
559
- const getFlag = (explicit, detector) => {
560
- return explicit || autoDetect && detector();
561
- };
562
- const isTypescriptEnabled = getFlag(typescript, hasTypescript);
563
- const isReactEnabled = getFlag(react, hasReact);
564
- const isAstroEnabled = getFlag(astro, hasAstro);
565
- const isTanstackQueryEnabled = getFlag(tanstackQuery, hasReactQuery);
566
- const isTestingLibraryEnabled = getFlag(testingLibrary, hasTestingLibrary);
567
- const isPlaywrightEnabled = getFlag(playwright, hasPlaywright);
568
- const isStorybookEnabled = getFlag(storybook, hasStorybook);
569
- const isNextjsEnabled = getFlag(nextjs, hasNext);
570
- const isJestEnabled = getFlag(jest, hasJest);
571
- const isVitestEnabled = getFlag(vitest, hasVitest);
572
- const baseConfigs = [
573
- javascriptConfig(),
574
- perfectionistConfig(),
575
- nodeConfig(),
576
- unicornConfig(),
577
- eslintCommentsConfig(),
578
- regexpConfig(),
579
- jsdocConfig(),
580
- importsConfig({ isTypescriptEnabled }),
581
- stylisticConfig()
582
- ];
583
- const featureConfigs = await Promise.all([
584
- isTypescriptEnabled && unwrap(import("./typescript-PLNEW3M4.js")),
585
- isReactEnabled && unwrap(import("./react-IAR3MTFF.js")),
586
- isTanstackQueryEnabled && unwrap(import("./tanstack-query-MM3M2QJO.js")),
587
- isAstroEnabled && unwrap(import("./astro-NEJ73UBN.js")),
588
- isJestEnabled && unwrap(import("./jest-SCRGNX6Z.js")),
589
- isVitestEnabled && unwrap(import("./vitest-IAENZQ7B.js")),
590
- isTestingLibraryEnabled && unwrap(import("./testing-library-QHZMYCZH.js")),
591
- isPlaywrightEnabled && unwrap(import("./playwright-2HMMFF3D.js")),
592
- isStorybookEnabled && unwrap(import("./storybook-XHFO7L4T.js")),
593
- isNextjsEnabled && unwrap(import("./nextjs-CRRBTFXP.js"))
594
- ]);
595
- return [
596
- ...baseConfigs,
597
- ...featureConfigs.filter(Boolean),
598
- commonjsConfig(),
599
- ignoresConfig(ignores),
600
- prettierConfig(),
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-DhqJ_65V.js")),
475
+ isReactEnabled && unwrap(import("./react-w3cMDj2s.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 };