@jpp-toolkit/eslint-config 0.0.11

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Julien Papini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ import { Config } from "eslint/config";
2
+
3
+ //#region src/index.d.ts
4
+
5
+ /**
6
+ * Creates a base ESLint configuration object with predefined defaults.
7
+ */
8
+ declare function createBaseEslintConfig(rootDir?: string, overrides?: Config[]): Config[];
9
+ /**
10
+ * Creates a React-specific ESLint configuration object with predefined defaults.
11
+ */
12
+ declare function createReactEslintConfig(rootDir?: string, overrides?: Config[]): Config[];
13
+ //#endregion
14
+ export { createBaseEslintConfig, createReactEslintConfig };
15
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,654 @@
1
+ import { defineConfig } from "eslint/config";
2
+ import globals from "globals";
3
+ import eslint from "@eslint/js";
4
+ import { includeIgnoreFile } from "@eslint/compat";
5
+ import { findGitIgnore } from "@jpp-toolkit/utils";
6
+ import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
7
+ import { createNodeResolver, importX } from "eslint-plugin-import-x";
8
+ import jsxA11y from "eslint-plugin-jsx-a11y";
9
+ import perfectionist from "eslint-plugin-perfectionist";
10
+ import prettier from "eslint-plugin-prettier/recommended";
11
+ import react from "eslint-plugin-react";
12
+ import reactHooks from "eslint-plugin-react-hooks";
13
+ import stylistic from "@stylistic/eslint-plugin";
14
+ import tseslint from "typescript-eslint";
15
+ import unicorn from "eslint-plugin-unicorn";
16
+ import vitest from "@vitest/eslint-plugin";
17
+
18
+ //#region src/configs/eslint-config.ts
19
+ /**
20
+ * ESLint configuration.
21
+ * @see {@link https://eslint.org/docs/latest/rules/}
22
+ */
23
+ const eslintConfig = defineConfig({
24
+ name: "eslint-config",
25
+ extends: [eslint.configs.recommended],
26
+ rules: {
27
+ "array-callback-return": ["error", {
28
+ checkForEach: true,
29
+ allowVoid: true
30
+ }],
31
+ "no-constructor-return": "error",
32
+ "no-duplicate-imports": "error",
33
+ "no-inner-declarations": "error",
34
+ "no-promise-executor-return": ["error", { allowVoid: true }],
35
+ "no-self-compare": "error",
36
+ "no-template-curly-in-string": "error",
37
+ "no-unassigned-vars": "error",
38
+ "no-unmodified-loop-condition": "error",
39
+ "no-unreachable-loop": "error",
40
+ "no-use-before-define": "error",
41
+ "no-useless-assignment": "error",
42
+ "require-atomic-updates": "error",
43
+ "arrow-body-style": "error",
44
+ "block-scoped-var": "error",
45
+ "camelcase": "error",
46
+ "consistent-return": "error",
47
+ "consistent-this": ["error", "self"],
48
+ "curly": [
49
+ "error",
50
+ "multi-or-nest",
51
+ "consistent"
52
+ ],
53
+ "default-case": "error",
54
+ "default-case-last": "error",
55
+ "default-param-last": "error",
56
+ "dot-notation": "error",
57
+ "eqeqeq": "error",
58
+ "func-style": [
59
+ "error",
60
+ "declaration",
61
+ { allowArrowFunctions: true }
62
+ ],
63
+ "grouped-accessor-pairs": ["error", "getBeforeSet"],
64
+ "guard-for-in": "error",
65
+ "logical-assignment-operators": "error",
66
+ "no-array-constructor": "error",
67
+ "no-caller": "error",
68
+ "no-div-regex": "error",
69
+ "no-empty-function": "error",
70
+ "no-eq-null": "error",
71
+ "no-eval": "error",
72
+ "no-extend-native": "error",
73
+ "no-extra-bind": "error",
74
+ "no-extra-label": "error",
75
+ "no-implicit-coercion": "error",
76
+ "no-implicit-globals": "error",
77
+ "no-implied-eval": "error",
78
+ "no-inline-comments": "error",
79
+ "no-invalid-this": "error",
80
+ "no-iterator": "error",
81
+ "no-label-var": "error",
82
+ "no-labels": "error",
83
+ "no-lone-blocks": "error",
84
+ "no-lonely-if": "error",
85
+ "no-loop-func": "error",
86
+ "no-multi-assign": "error",
87
+ "no-new": "error",
88
+ "no-new-func": "error",
89
+ "no-new-wrappers": "error",
90
+ "no-object-constructor": "error",
91
+ "no-octal-escape": "error",
92
+ "no-param-reassign": "error",
93
+ "no-plusplus": "error",
94
+ "no-proto": "error",
95
+ "no-return-assign": "error",
96
+ "no-script-url": "error",
97
+ "no-sequences": "error",
98
+ "no-shadow": "error",
99
+ "no-throw-literal": "error",
100
+ "no-undef-init": "error",
101
+ "no-unneeded-ternary": "error",
102
+ "no-unused-expressions": "error",
103
+ "no-useless-call": "error",
104
+ "no-useless-computed-key": "error",
105
+ "no-useless-concat": "error",
106
+ "no-useless-constructor": "error",
107
+ "no-useless-rename": "error",
108
+ "no-useless-return": "error",
109
+ "no-var": "error",
110
+ "object-shorthand": "error",
111
+ "operator-assignment": "error",
112
+ "prefer-arrow-callback": "error",
113
+ "prefer-const": "error",
114
+ "prefer-destructuring": "error",
115
+ "prefer-exponentiation-operator": "error",
116
+ "prefer-named-capture-group": "error",
117
+ "prefer-numeric-literals": "error",
118
+ "prefer-object-has-own": "error",
119
+ "prefer-object-spread": "error",
120
+ "prefer-promise-reject-errors": "error",
121
+ "prefer-regex-literals": "error",
122
+ "prefer-rest-params": "error",
123
+ "prefer-spread": "error",
124
+ "prefer-template": "error",
125
+ "radix": ["error", "as-needed"],
126
+ "require-await": "error",
127
+ "require-unicode-regexp": "error",
128
+ "sort-imports": "error",
129
+ "symbol-description": "error"
130
+ }
131
+ });
132
+
133
+ //#endregion
134
+ //#region src/configs/ignore-config.ts
135
+ /**
136
+ * Generates an ESLint configuration that ignores files based on the project's .gitignore.
137
+ * @see {@link https://eslint.org/docs/latest/use/configure/ignore#including-gitignore-files}
138
+ */
139
+ const ignoreConfig = (rootDir) => {
140
+ return defineConfig({
141
+ name: "ignore-config",
142
+ extends: [includeIgnoreFile(findGitIgnore(rootDir))]
143
+ });
144
+ };
145
+
146
+ //#endregion
147
+ //#region src/configs/import-x-config.ts
148
+ /**
149
+ * Import X configuration.
150
+ * @see {@link https://github.com/un-ts/eslint-plugin-import-x}
151
+ */
152
+ const importXConfig = defineConfig([{
153
+ name: "import-x-config",
154
+ extends: [importX.flatConfigs.recommended],
155
+ settings: { "import-x/resolver-next": [createNodeResolver()] },
156
+ rules: {
157
+ "import-x/no-empty-named-blocks": "error",
158
+ "import-x/no-mutable-exports": "error",
159
+ "import-x/no-rename-default": "off",
160
+ "import-x/no-unused-modules": "error",
161
+ "import-x/no-absolute-path": "error",
162
+ "import-x/no-cycle": "error",
163
+ "import-x/no-relative-packages": "error",
164
+ "import-x/no-self-import": "error",
165
+ "import-x/no-useless-path-segments": "error",
166
+ "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
167
+ "import-x/first": "error",
168
+ "import-x/newline-after-import": "error",
169
+ "import-x/no-named-as-default": "off",
170
+ "import-x/no-named-as-default-member": "off",
171
+ "import-x/no-unresolved": "off",
172
+ "no-duplicate-imports": "off"
173
+ }
174
+ }, {
175
+ name: "import-x-config-typescript",
176
+ files: ["**/*.{ts,tsx}"],
177
+ extends: [importX.flatConfigs.typescript],
178
+ settings: { "import-x/resolver-next": [createTypeScriptImportResolver(), createNodeResolver()] }
179
+ }]);
180
+
181
+ //#endregion
182
+ //#region src/configs/jsx-a11y-config.ts
183
+ /**
184
+ * JSX a11y configuration.
185
+ * @see {@link https://github.com/jsx-eslint/eslint-plugin-jsx-a11y}
186
+ */
187
+ const jsxA11yConfig = defineConfig({
188
+ name: "jsx-a11y-config",
189
+ extends: [jsxA11y.flatConfigs.recommended],
190
+ rules: {}
191
+ });
192
+
193
+ //#endregion
194
+ //#region src/configs/perfectionist-config.ts
195
+ /**
196
+ * Perfectionist configuration.
197
+ * @see {@link https://perfectionist.dev/rules}
198
+ */
199
+ const perfectionistConfig = defineConfig({
200
+ name: "perfectionist-config",
201
+ plugins: { perfectionist },
202
+ rules: {
203
+ "perfectionist/sort-array-includes": "error",
204
+ "perfectionist/sort-decorators": "error",
205
+ "perfectionist/sort-exports": ["error", {
206
+ type: "natural",
207
+ order: "asc",
208
+ groupKind: "types-first"
209
+ }],
210
+ "perfectionist/sort-heritage-clauses": "error",
211
+ "sort-imports": "off",
212
+ "perfectionist/sort-imports": ["error", {
213
+ type: "natural",
214
+ order: "asc",
215
+ internalPattern: ["^~.*"],
216
+ newlinesBetween: "always",
217
+ groups: [
218
+ ["side-effect", "side-effect-style"],
219
+ ["builtin-type", "builtin"],
220
+ ["external-type", "external"],
221
+ ["internal-type", "internal"],
222
+ ["parent-type", "parent"],
223
+ ["sibling-type", "sibling"],
224
+ ["index-type", "index"],
225
+ ["object"],
226
+ ["style"],
227
+ ["unknown"]
228
+ ]
229
+ }]
230
+ }
231
+ });
232
+
233
+ //#endregion
234
+ //#region src/configs/prettier-config.ts
235
+ /**
236
+ * Prettier configuration.
237
+ * @see {@link https://github.com/prettier/eslint-plugin-prettier}
238
+ */
239
+ const prettierConfig = defineConfig({
240
+ name: "prettier-config",
241
+ extends: [prettier]
242
+ });
243
+
244
+ //#endregion
245
+ //#region src/configs/react-config.ts
246
+ /**
247
+ * React configuration.
248
+ * @see {@link https://github.com/jsx-eslint/eslint-plugin-react}
249
+ */
250
+ const reactConfig = defineConfig({
251
+ name: "react-config",
252
+ extends: [react.configs.flat["recommended"], react.configs.flat["jsx-runtime"]],
253
+ settings: { react: { version: "detect" } },
254
+ rules: {
255
+ "react/boolean-prop-naming": ["error", {
256
+ rule: "^(is|has|can|should)[A-Z][A-Za-z0-9]*",
257
+ validateNested: true
258
+ }],
259
+ "react/button-has-type": "error",
260
+ "react/checked-requires-onchange-or-readonly": "error",
261
+ "react/default-props-match-prop-types": "error",
262
+ "react/destructuring-assignment": "error",
263
+ "react/forward-ref-uses-ref": "error",
264
+ "react/function-component-definition": ["error", {
265
+ namedComponents: "arrow-function",
266
+ unnamedComponents: "arrow-function"
267
+ }],
268
+ "react/hook-use-state": "error",
269
+ "react/iframe-missing-sandbox": "error",
270
+ "react/jsx-boolean-value": ["error", "never"],
271
+ "react/jsx-child-element-spacing": "error",
272
+ "react/jsx-closing-bracket-location": "error",
273
+ "react/jsx-closing-tag-location": "error",
274
+ "react/jsx-curly-brace-presence": ["error", "never"],
275
+ "react/jsx-curly-newline": "error",
276
+ "react/jsx-curly-spacing": "error",
277
+ "react/jsx-equals-spacing": "error",
278
+ "react/jsx-first-prop-new-line": "error",
279
+ "react/jsx-fragments": "error",
280
+ "react/jsx-handler-names": "error",
281
+ "react/jsx-indent": "error",
282
+ "react/jsx-indent-props": "error",
283
+ "react/jsx-no-bind": "error",
284
+ "react/jsx-no-constructed-context-values": "error",
285
+ "react/jsx-no-leaked-render": "error",
286
+ "react/jsx-no-script-url": "error",
287
+ "react/jsx-no-useless-fragment": "error",
288
+ "react/jsx-one-expression-per-line": "error",
289
+ "react/jsx-pascal-case": "error",
290
+ "react/jsx-props-no-multi-spaces": "error",
291
+ "react/jsx-props-no-spread-multi": "error",
292
+ "react/jsx-sort-props": ["error", {
293
+ callbacksLast: true,
294
+ shorthandLast: true,
295
+ multiline: "last",
296
+ ignoreCase: false,
297
+ noSortAlphabetically: false,
298
+ reservedFirst: true
299
+ }],
300
+ "react/jsx-tag-spacing": "error",
301
+ "react/jsx-wrap-multilines": "error",
302
+ "react/no-access-state-in-setstate": "error",
303
+ "react/no-adjacent-inline-elements": "error",
304
+ "react/no-array-index-key": "error",
305
+ "react/no-arrow-function-lifecycle": "error",
306
+ "react/no-danger": "error",
307
+ "react/no-did-mount-set-state": "error",
308
+ "react/no-did-update-set-state": "error",
309
+ "react/no-invalid-html-attribute": "error",
310
+ "react/no-namespace": "error",
311
+ "react/no-object-type-as-default-prop": "error",
312
+ "react/no-redundant-should-component-update": "error",
313
+ "react/no-set-state": "error",
314
+ "react/no-this-in-sfc": "error",
315
+ "react/no-typos": "error",
316
+ "react/no-unstable-nested-components": "error",
317
+ "react/no-unused-class-component-methods": "error",
318
+ "react/no-unused-prop-types": "error",
319
+ "react/no-unused-state": "error",
320
+ "react/no-will-update-set-state": "error",
321
+ "react/prefer-es6-class": "error",
322
+ "react/prefer-exact-props": "error",
323
+ "react/prefer-read-only-props": "error",
324
+ "react/prefer-stateless-function": "error",
325
+ "react/require-default-props": "error",
326
+ "react/require-optimization": "error",
327
+ "react/self-closing-comp": "error",
328
+ "react/sort-comp": "error",
329
+ "react/sort-default-props": "error",
330
+ "react/sort-prop-types": "error",
331
+ "react/state-in-constructor": "error",
332
+ "react/static-property-placement": "error",
333
+ "react/void-dom-elements-no-children": "error"
334
+ }
335
+ });
336
+
337
+ //#endregion
338
+ //#region src/configs/react-hooks-config.ts
339
+ /**
340
+ * React hooks configuration.
341
+ * @see {@link https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks}
342
+ */
343
+ const reactHooksConfig = defineConfig({
344
+ name: "react-hooks-config",
345
+ extends: [reactHooks.configs.flat.recommended]
346
+ });
347
+
348
+ //#endregion
349
+ //#region src/configs/stylistic-config.ts
350
+ /**
351
+ * Stylistic configuration.
352
+ * @see {@link https://eslint.style/rules}
353
+ */
354
+ const stylisticConfig = defineConfig({
355
+ name: "stylistic-config",
356
+ plugins: { "@stylistic": stylistic },
357
+ rules: { "@stylistic/quotes": [
358
+ "error",
359
+ "single",
360
+ {
361
+ avoidEscape: true,
362
+ allowTemplateLiterals: false
363
+ }
364
+ ] }
365
+ });
366
+
367
+ //#endregion
368
+ //#region src/configs/typescript-config.ts
369
+ /**
370
+ * TypeScript configuration.
371
+ * @see {@link https://typescript-eslint.io/rules/}
372
+ */
373
+ const typescriptConfig = defineConfig([{
374
+ name: "typescript-config",
375
+ files: ["**/*.{ts,tsx}"],
376
+ extends: [tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked],
377
+ languageOptions: { parserOptions: { projectService: true } },
378
+ rules: {
379
+ "@typescript-eslint/consistent-type-exports": "error",
380
+ "@typescript-eslint/consistent-type-imports": "error",
381
+ "default-param-last": "off",
382
+ "@typescript-eslint/default-param-last": "error",
383
+ "@typescript-eslint/explicit-member-accessibility": ["error", {
384
+ accessibility: "explicit",
385
+ overrides: {
386
+ accessors: "explicit",
387
+ constructors: "no-public",
388
+ methods: "explicit",
389
+ properties: "no-public",
390
+ parameterProperties: "no-public"
391
+ }
392
+ }],
393
+ "@typescript-eslint/member-ordering": ["error", { default: [
394
+ "signature",
395
+ "call-signature",
396
+ "public-static-field",
397
+ "protected-static-field",
398
+ "private-static-field",
399
+ "#private-static-field",
400
+ "public-instance-field",
401
+ "protected-instance-field",
402
+ "private-instance-field",
403
+ "#private-instance-field",
404
+ "public-abstract-field",
405
+ "protected-abstract-field",
406
+ "public-field",
407
+ "protected-field",
408
+ "private-field",
409
+ "#private-field",
410
+ "static-field",
411
+ "instance-field",
412
+ "abstract-field",
413
+ "field",
414
+ "static-initialization",
415
+ "public-constructor",
416
+ "protected-constructor",
417
+ "private-constructor",
418
+ "public-static-accessor",
419
+ "protected-static-accessor",
420
+ "private-static-accessor",
421
+ "#private-static-accessor",
422
+ "public-instance-accessor",
423
+ "protected-instance-accessor",
424
+ "private-instance-accessor",
425
+ "#private-instance-accessor",
426
+ "public-abstract-accessor",
427
+ "protected-abstract-accessor",
428
+ "public-accessor",
429
+ "protected-accessor",
430
+ "private-accessor",
431
+ "#private-accessor",
432
+ "static-accessor",
433
+ "instance-accessor",
434
+ "abstract-accessor",
435
+ "accessor",
436
+ ["public-static-get", "public-static-set"],
437
+ ["protected-static-get", "protected-static-set"],
438
+ ["private-static-get", "private-static-set"],
439
+ ["#private-static-get", "#private-static-set"],
440
+ ["public-instance-get", "public-instance-set"],
441
+ ["protected-instance-get", "protected-instance-set"],
442
+ ["private-instance-get", "private-instance-set"],
443
+ ["#private-instance-get", "#private-instance-set"],
444
+ ["public-abstract-get", "public-abstract-set"],
445
+ ["protected-abstract-get", "protected-abstract-set"],
446
+ ["public-get", "public-set"],
447
+ ["protected-get", "protected-set"],
448
+ ["private-get", "private-set"],
449
+ ["#private-get", "#private-set"],
450
+ ["static-get", "static-set"],
451
+ ["instance-get", "instance-set"],
452
+ ["abstract-get", "abstract-set"],
453
+ ["get", "set"],
454
+ "public-static-method",
455
+ "protected-static-method",
456
+ "private-static-method",
457
+ "#private-static-method",
458
+ "public-instance-method",
459
+ "protected-instance-method",
460
+ "private-instance-method",
461
+ "#private-instance-method",
462
+ "public-abstract-method",
463
+ "protected-abstract-method",
464
+ "public-method",
465
+ "protected-method",
466
+ "private-method",
467
+ "#private-method",
468
+ "static-method",
469
+ "instance-method",
470
+ "abstract-method",
471
+ "method"
472
+ ] }],
473
+ "@typescript-eslint/method-signature-style": "error",
474
+ "@typescript-eslint/naming-convention": [
475
+ "error",
476
+ {
477
+ selector: "typeParameter",
478
+ format: ["PascalCase"],
479
+ prefix: [
480
+ "T",
481
+ "K",
482
+ "U",
483
+ "V"
484
+ ]
485
+ },
486
+ {
487
+ selector: [
488
+ "method",
489
+ "parameterProperty",
490
+ "property"
491
+ ],
492
+ modifiers: ["private"],
493
+ format: ["camelCase"],
494
+ leadingUnderscore: "require"
495
+ },
496
+ {
497
+ selector: ["interface", "typeAlias"],
498
+ format: ["PascalCase"]
499
+ }
500
+ ],
501
+ "@typescript-eslint/no-import-type-side-effects": "error",
502
+ "no-invalid-this": "off",
503
+ "@typescript-eslint/no-invalid-this": "error",
504
+ "no-loop-func": "off",
505
+ "@typescript-eslint/no-loop-func": "error",
506
+ "no-shadow": "off",
507
+ "@typescript-eslint/no-shadow": "error",
508
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
509
+ "@typescript-eslint/no-unnecessary-qualifier": "error",
510
+ "no-use-before-define": "off",
511
+ "@typescript-eslint/no-use-before-define": "error",
512
+ "@typescript-eslint/no-useless-empty-export": "error",
513
+ "@typescript-eslint/parameter-properties": "error",
514
+ "prefer-destructuring": "off",
515
+ "@typescript-eslint/prefer-destructuring": "error",
516
+ "@typescript-eslint/prefer-enum-initializers": "error",
517
+ "@typescript-eslint/prefer-readonly": "error",
518
+ "@typescript-eslint/promise-function-async": "error",
519
+ "@typescript-eslint/require-array-sort-compare": "error",
520
+ "@typescript-eslint/consistent-type-definitions": ["error", "type"],
521
+ "@typescript-eslint/no-confusing-void-expression": ["error", {
522
+ ignoreVoidOperator: true,
523
+ ignoreVoidReturningFunctions: true
524
+ }],
525
+ "@typescript-eslint/no-explicit-any": ["error", { ignoreRestArgs: true }],
526
+ "@typescript-eslint/no-extraneous-class": "off",
527
+ "@typescript-eslint/no-non-null-assertion": "off",
528
+ "@typescript-eslint/no-unused-vars": ["error", {
529
+ args: "all",
530
+ argsIgnorePattern: "^_",
531
+ caughtErrors: "all",
532
+ caughtErrorsIgnorePattern: "^_",
533
+ destructuredArrayIgnorePattern: "^_",
534
+ varsIgnorePattern: "^_",
535
+ ignoreRestSiblings: true
536
+ }],
537
+ "@typescript-eslint/restrict-template-expressions": "off",
538
+ "@typescript-eslint/unbound-method": ["error", { ignoreStatic: true }]
539
+ }
540
+ }, {
541
+ name: "typescript-config-dts",
542
+ files: ["**/*.d.ts"],
543
+ rules: {
544
+ "@typescript-eslint/consistent-type-definitions": "off",
545
+ "@typescript-eslint/naming-convention": "off"
546
+ }
547
+ }]);
548
+
549
+ //#endregion
550
+ //#region src/configs/unicorn-config.ts
551
+ /**
552
+ * Unicorn configuration.
553
+ * @see {@link https://github.com/sindresorhus/eslint-plugin-unicorn}
554
+ */
555
+ const unicornConfig = defineConfig({
556
+ name: "unicorn-config",
557
+ plugins: { unicorn },
558
+ rules: {
559
+ "unicorn/filename-case": ["error", { case: "kebabCase" }],
560
+ "unicorn/prefer-node-protocol": "error"
561
+ }
562
+ });
563
+
564
+ //#endregion
565
+ //#region src/configs/vitest-config.ts
566
+ /**
567
+ * Vitest configuration.
568
+ * @see {@link https://github.com/vitest-dev/eslint-plugin-vitest}
569
+ */
570
+ const vitestConfig = defineConfig({
571
+ name: "vitest-config",
572
+ files: ["**/*.{spec,test}.{js,jsx,ts,tsx}"],
573
+ extends: [vitest.configs.recommended],
574
+ settings: { vitest: { typecheck: true } },
575
+ languageOptions: { globals: { ...vitest.environments.env.globals } },
576
+ rules: {
577
+ "vitest/consistent-test-it": ["error", { fn: "it" }],
578
+ "vitest/no-conditional-in-test": "error",
579
+ "vitest/no-duplicate-hooks": "error",
580
+ "vitest/no-test-return-statement": "error",
581
+ "vitest/padding-around-all": "error",
582
+ "vitest/prefer-called-with": "error",
583
+ "vitest/prefer-comparison-matcher": "error",
584
+ "vitest/prefer-each": "error",
585
+ "vitest/prefer-equality-matcher": "error",
586
+ "vitest/prefer-expect-assertions": "error",
587
+ "vitest/prefer-expect-resolves": "error",
588
+ "vitest/prefer-hooks-in-order": "error",
589
+ "vitest/prefer-hooks-on-top": "error",
590
+ "vitest/prefer-lowercase-title": ["error", { ignore: ["describe"] }],
591
+ "vitest/prefer-mock-promise-shorthand": "error",
592
+ "vitest/prefer-snapshot-hint": "error",
593
+ "vitest/prefer-spy-on": "error",
594
+ "vitest/prefer-strict-equal": "error",
595
+ "vitest/prefer-todo": "error",
596
+ "vitest/prefer-vi-mocked": "error",
597
+ "vitest/require-to-throw-message": "error",
598
+ "vitest/require-top-level-describe": "error",
599
+ "vitest/valid-title": ["error", { mustMatch: { test: "^should" } }]
600
+ }
601
+ });
602
+
603
+ //#endregion
604
+ //#region src/index.ts
605
+ /**
606
+ * Creates a base ESLint configuration object with predefined defaults.
607
+ */
608
+ function createBaseEslintConfig(rootDir, overrides = []) {
609
+ return defineConfig([
610
+ ignoreConfig(rootDir),
611
+ eslintConfig,
612
+ stylisticConfig,
613
+ importXConfig,
614
+ perfectionistConfig,
615
+ unicornConfig,
616
+ typescriptConfig,
617
+ vitestConfig,
618
+ ...overrides,
619
+ prettierConfig,
620
+ {
621
+ name: "language-config",
622
+ languageOptions: {
623
+ ecmaVersion: "latest",
624
+ globals: { ...globals.node }
625
+ }
626
+ }
627
+ ]);
628
+ }
629
+ /**
630
+ * Creates a React-specific ESLint configuration object with predefined defaults.
631
+ */
632
+ function createReactEslintConfig(rootDir, overrides = []) {
633
+ return defineConfig([
634
+ createBaseEslintConfig(rootDir, overrides),
635
+ {
636
+ name: "typescript-config",
637
+ files: ["**/*.{ts,tsx}"],
638
+ rules: { "@typescript-eslint/no-empty-object-type": "off" }
639
+ },
640
+ reactConfig,
641
+ reactHooksConfig,
642
+ jsxA11yConfig,
643
+ ...overrides,
644
+ prettierConfig,
645
+ {
646
+ name: "language-config",
647
+ languageOptions: { globals: { ...globals.browser } }
648
+ }
649
+ ]);
650
+ }
651
+
652
+ //#endregion
653
+ export { createBaseEslintConfig, createReactEslintConfig };
654
+ //# sourceMappingURL=index.mjs.map