@jimmy.codes/eslint-config 6.21.0 → 6.23.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/README.md +39 -1
- package/dist/{astro-D3Zl135N.mjs → astro-DNtOkeq5.mjs} +1 -1
- package/dist/{globs-C_yfK842.mjs → globs-uKx5b8lV.mjs} +11 -3
- package/dist/globs.d.mts +2 -1
- package/dist/globs.mjs +2 -2
- package/dist/index.d.mts +22 -2
- package/dist/index.mjs +42 -25
- package/dist/{jest-DZtYWPoX.mjs → jest-DgTHyrfz.mjs} +1 -1
- package/dist/{nextjs-DEk_ANZ4.mjs → nextjs-VPeisXpq.mjs} +1 -1
- package/dist/{playwright-CrBcE3qD.mjs → playwright-CM4et1Wx.mjs} +1 -1
- package/dist/{react-sWdvHd_J.mjs → react-DY8zODCu.mjs} +1 -1
- package/dist/{tanstack-query-D1gpzKY3.mjs → tanstack-query-DG6a41GH.mjs} +1 -1
- package/dist/{testing-library-BBWV3thw.mjs → testing-library-oE675dT3.mjs} +1 -1
- package/dist/{typescript-w0LuBIDT.mjs → typescript-CMkBsIGI.mjs} +1 -1
- package/dist/{vitest-57vZrKwy.mjs → vitest-C4QXivmM.mjs} +24 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ import { defineConfig } from "@jimmy.codes/eslint-config";
|
|
|
42
42
|
export default defineConfig();
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
It
|
|
45
|
+
It'll auto-configure based on your installed dependencies.
|
|
46
46
|
|
|
47
47
|
---
|
|
48
48
|
|
|
@@ -75,6 +75,44 @@ export default defineConfig({
|
|
|
75
75
|
});
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
### Vitest Configuration
|
|
79
|
+
|
|
80
|
+
Vitest also supports some configuration options. If options are provided then Vitest support is enabled.
|
|
81
|
+
|
|
82
|
+
#### Configure Vitest Globals
|
|
83
|
+
|
|
84
|
+
Control how [Vitest globals configuration](https://vitest.dev/config/globals.html) (`describe`, `it`, `expect`, etc.) are handled:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { defineConfig } from "@jimmy.codes/eslint-config";
|
|
88
|
+
|
|
89
|
+
export default defineConfig({
|
|
90
|
+
vitest: {
|
|
91
|
+
globals: "explicit", // Require explicit imports from 'vitest'
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Options:
|
|
97
|
+
|
|
98
|
+
- `'explicit'`: Require explicit imports from `'vitest'`
|
|
99
|
+
- `'implicit'`: Use implicit global APIs (vitest config `globals: true`)
|
|
100
|
+
- `'either'`: Allow both styles (default)
|
|
101
|
+
|
|
102
|
+
#### Configure Type Testing
|
|
103
|
+
|
|
104
|
+
Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) (`expectTypeOf`, `assertType`) are being used:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { defineConfig } from "@jimmy.codes/eslint-config";
|
|
108
|
+
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
vitest: {
|
|
111
|
+
typecheck: true,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
78
116
|
### Override Specific Rules
|
|
79
117
|
|
|
80
118
|
```ts
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
//#region src/globs.ts
|
|
2
2
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
3
|
+
const GLOB_TS_EXT = "?([cm])ts";
|
|
4
|
+
const GLOB_TSX_EXT = "?([cm])tsx";
|
|
3
5
|
const GLOB_JS = "**/*.?([cm])js";
|
|
4
6
|
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
5
7
|
const GLOB_CJS = "**/*.cjs";
|
|
6
|
-
const GLOB_TS =
|
|
7
|
-
const GLOB_TSX =
|
|
8
|
+
const GLOB_TS = `**/*.${GLOB_TS_EXT}`;
|
|
9
|
+
const GLOB_TSX = `**/*.${GLOB_TSX_EXT}`;
|
|
8
10
|
const GLOB_ASTRO = "**/*.astro";
|
|
9
11
|
const GLOB_TESTS = [
|
|
10
12
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -13,6 +15,12 @@ const GLOB_TESTS = [
|
|
|
13
15
|
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
14
16
|
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
15
17
|
];
|
|
18
|
+
const GLOB_TYPE_TESTS = [
|
|
19
|
+
`**/*.test-d.${GLOB_TS_EXT}`,
|
|
20
|
+
`**/*.test-d.${GLOB_TSX_EXT}`,
|
|
21
|
+
`**/*.spec-d.${GLOB_TS_EXT}`,
|
|
22
|
+
`**/*.spec-d.${GLOB_TSX_EXT}`
|
|
23
|
+
];
|
|
16
24
|
const GLOB_PLAYWRIGHT = [`**/e2e/**/*.spec.${GLOB_SRC_EXT}`, `**/e2e/**/*.test.${GLOB_SRC_EXT}`];
|
|
17
25
|
const GLOB_E2E = [
|
|
18
26
|
...GLOB_PLAYWRIGHT,
|
|
@@ -69,4 +77,4 @@ const GLOB_IGNORES = [
|
|
|
69
77
|
];
|
|
70
78
|
|
|
71
79
|
//#endregion
|
|
72
|
-
export { GLOB_JS as a, GLOB_PLAYWRIGHT as c, GLOB_TSX as d, GLOB_IGNORES as i, GLOB_TESTS as l, GLOB_CJS as n, GLOB_JSX as o, GLOB_E2E as r, GLOB_NEXTJS as s, GLOB_ASTRO as t, GLOB_TS as u };
|
|
80
|
+
export { GLOB_JS as a, GLOB_PLAYWRIGHT as c, GLOB_TSX as d, GLOB_TYPE_TESTS as f, GLOB_IGNORES as i, GLOB_TESTS as l, GLOB_CJS as n, GLOB_JSX as o, GLOB_E2E as r, GLOB_NEXTJS as s, GLOB_ASTRO as t, GLOB_TS as u };
|
package/dist/globs.d.mts
CHANGED
|
@@ -6,9 +6,10 @@ declare const GLOB_TS = "**/*.?([cm])ts";
|
|
|
6
6
|
declare const GLOB_TSX = "**/*.?([cm])tsx";
|
|
7
7
|
declare const GLOB_ASTRO = "**/*.astro";
|
|
8
8
|
declare const GLOB_TESTS: readonly ["**/__tests__/**/*.?([cm])[jt]s?(x)", "**/*.spec.?([cm])[jt]s?(x)", "**/*.test.?([cm])[jt]s?(x)", "**/*.bench.?([cm])[jt]s?(x)", "**/*.benchmark.?([cm])[jt]s?(x)"];
|
|
9
|
+
declare const GLOB_TYPE_TESTS: readonly ["**/*.test-d.?([cm])ts", "**/*.test-d.?([cm])tsx", "**/*.spec-d.?([cm])ts", "**/*.spec-d.?([cm])tsx"];
|
|
9
10
|
declare const GLOB_PLAYWRIGHT: readonly ["**/e2e/**/*.spec.?([cm])[jt]s?(x)", "**/e2e/**/*.test.?([cm])[jt]s?(x)"];
|
|
10
11
|
declare const GLOB_E2E: readonly ["**/e2e/**/*.spec.?([cm])[jt]s?(x)", "**/e2e/**/*.test.?([cm])[jt]s?(x)", "**/cypress/**/*.spec.?([cm])[jt]s?(x)", "**/cypress/**/*.test.?([cm])[jt]s?(x)"];
|
|
11
12
|
declare const GLOB_NEXTJS: readonly ["**/*.?([cm])js", "**/*.?([cm])jsx", "**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
12
13
|
declare const GLOB_IGNORES: readonly ["**/node_modules", "**/dist", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/bun.lockb", "**/output", "**/coverage", "**/temp", "**/.temp", "**/tmp", "**/.tmp", "**/.history", "**/.vitepress/cache", "**/.nuxt", "**/.next", "**/.vercel", "**/.changeset", "**/.idea", "**/.cache", "**/.output", "**/.vite-inspect", "**/.yarn", "**/storybook-static", "**/.eslint-config-inspector", "**/playwright-report", "**/.astro", "**/.vinxi", "**/app.config.timestamp_*.js", "**/.tanstack", "**/.nitro", "**/CHANGELOG*.md", "**/*.min.*", "**/LICENSE*", "**/__snapshots__", "**/auto-import?(s).d.ts", "**/components.d.ts", "**/vite.config.ts.*.mjs", "**/*.gen.*", "!.storybook"];
|
|
13
14
|
//#endregion
|
|
14
|
-
export { GLOB_ASTRO, GLOB_CJS, GLOB_E2E, GLOB_IGNORES, GLOB_JS, GLOB_JSX, GLOB_NEXTJS, GLOB_PLAYWRIGHT, GLOB_TESTS, GLOB_TS, GLOB_TSX };
|
|
15
|
+
export { GLOB_ASTRO, GLOB_CJS, GLOB_E2E, GLOB_IGNORES, GLOB_JS, GLOB_JSX, GLOB_NEXTJS, GLOB_PLAYWRIGHT, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_TYPE_TESTS };
|
package/dist/globs.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as GLOB_JS, c as GLOB_PLAYWRIGHT, d as GLOB_TSX, i as GLOB_IGNORES, l as GLOB_TESTS, n as GLOB_CJS, o as GLOB_JSX, r as GLOB_E2E, s as GLOB_NEXTJS, t as GLOB_ASTRO, u as GLOB_TS } from "./globs-
|
|
1
|
+
import { a as GLOB_JS, c as GLOB_PLAYWRIGHT, d as GLOB_TSX, f as GLOB_TYPE_TESTS, i as GLOB_IGNORES, l as GLOB_TESTS, n as GLOB_CJS, o as GLOB_JSX, r as GLOB_E2E, s as GLOB_NEXTJS, t as GLOB_ASTRO, u as GLOB_TS } from "./globs-uKx5b8lV.mjs";
|
|
2
2
|
|
|
3
|
-
export { GLOB_ASTRO, GLOB_CJS, GLOB_E2E, GLOB_IGNORES, GLOB_JS, GLOB_JSX, GLOB_NEXTJS, GLOB_PLAYWRIGHT, GLOB_TESTS, GLOB_TS, GLOB_TSX };
|
|
3
|
+
export { GLOB_ASTRO, GLOB_CJS, GLOB_E2E, GLOB_IGNORES, GLOB_JS, GLOB_JSX, GLOB_NEXTJS, GLOB_PLAYWRIGHT, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_TYPE_TESTS };
|
package/dist/index.d.mts
CHANGED
|
@@ -15004,6 +15004,26 @@ interface LinterConfigOverrides {
|
|
|
15004
15004
|
plugins?: Record<string, unknown>;
|
|
15005
15005
|
}
|
|
15006
15006
|
type TypedConfigItem = Prettify<Override<Base, LinterConfigOverrides>>;
|
|
15007
|
+
interface VitestOptions {
|
|
15008
|
+
/**
|
|
15009
|
+
* How to handle Vitest global APIs (describe, it, expect, etc.).
|
|
15010
|
+
*
|
|
15011
|
+
* - 'explicit': Require explicit imports from 'vitest'
|
|
15012
|
+
* - 'implicit': Use implicit global APIs (vitest config globals: true)
|
|
15013
|
+
* - 'either': Allow both styles (default)
|
|
15014
|
+
*
|
|
15015
|
+
* @see https://vitest.dev/config/globals.html
|
|
15016
|
+
*
|
|
15017
|
+
* @default 'either'
|
|
15018
|
+
*/
|
|
15019
|
+
globals?: "either" | "explicit" | "implicit";
|
|
15020
|
+
/**
|
|
15021
|
+
* Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) (`expectTypeOf`, `assertType`) are being used
|
|
15022
|
+
*
|
|
15023
|
+
* @default false
|
|
15024
|
+
*/
|
|
15025
|
+
typecheck?: boolean;
|
|
15026
|
+
}
|
|
15007
15027
|
interface Options {
|
|
15008
15028
|
/**
|
|
15009
15029
|
* Are astro rules enabled?
|
|
@@ -15091,7 +15111,7 @@ interface Options {
|
|
|
15091
15111
|
*
|
|
15092
15112
|
* @default false
|
|
15093
15113
|
*/
|
|
15094
|
-
vitest?: boolean;
|
|
15114
|
+
vitest?: boolean | VitestOptions;
|
|
15095
15115
|
}
|
|
15096
15116
|
//#endregion
|
|
15097
15117
|
//#region src/factory.d.ts
|
|
@@ -15122,4 +15142,4 @@ declare const defineConfig: ({
|
|
|
15122
15142
|
vitest
|
|
15123
15143
|
}?: Options, ...moreOverrides: Linter.Config[] | TypedConfigItem[]) => Promise<any[]>;
|
|
15124
15144
|
//#endregion
|
|
15125
|
-
export { Options,
|
|
15145
|
+
export { type Options, type TypedConfigItem, type VitestOptions, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as GLOB_IGNORES, l as GLOB_TESTS, n as GLOB_CJS } from "./globs-
|
|
1
|
+
import { i as GLOB_IGNORES, l as GLOB_TESTS, n as GLOB_CJS } from "./globs-uKx5b8lV.mjs";
|
|
2
2
|
import { a as hasReact, c as hasTestingLibrary, d as hasVitest, i as hasPlaywright, l as hasTypescript, n as hasJest, o as hasReactQuery, r as hasNext, s as hasStorybook, t as hasAstro } from "./has-dependency-BreXO1rF.mjs";
|
|
3
3
|
import gitignoreConfig from "eslint-config-flat-gitignore";
|
|
4
4
|
import globals from "globals";
|
|
@@ -424,6 +424,22 @@ const unicornConfig = () => {
|
|
|
424
424
|
}];
|
|
425
425
|
};
|
|
426
426
|
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region src/utils/create-featured.ts
|
|
429
|
+
/**
|
|
430
|
+
* Creates a featured flag checker function.
|
|
431
|
+
*
|
|
432
|
+
* @param autoDetect - Whether to auto-detect features.
|
|
433
|
+
*
|
|
434
|
+
* @returns A function that determines if a feature is enabled.
|
|
435
|
+
*/
|
|
436
|
+
const createFeatured = (autoDetect) => {
|
|
437
|
+
return (explicit, detector) => {
|
|
438
|
+
if (typeof explicit !== "boolean") return true;
|
|
439
|
+
return explicit || autoDetect && detector();
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
|
|
427
443
|
//#endregion
|
|
428
444
|
//#region src/utils/unwrap.ts
|
|
429
445
|
/**
|
|
@@ -436,16 +452,19 @@ const unicornConfig = () => {
|
|
|
436
452
|
*
|
|
437
453
|
* @param module - A dynamically imported module.
|
|
438
454
|
*
|
|
455
|
+
* @param args - Optional arguments forwarded to the module's default export if it's a function.
|
|
456
|
+
*
|
|
439
457
|
* @returns
|
|
440
458
|
* If the module has a `default` export that is a function, it returns the result of calling it.
|
|
441
459
|
* Otherwise, it returns the module itself.
|
|
442
460
|
*
|
|
443
461
|
* @example
|
|
444
462
|
* const config = await unwrap(import("./configs/react"));
|
|
463
|
+
* const configWithOptions = await unwrap(import("./configs/react"), { version: "12" });
|
|
445
464
|
*/
|
|
446
|
-
const unwrap = async (module) => {
|
|
465
|
+
const unwrap = async (module, ...args) => {
|
|
447
466
|
const resolved = await module;
|
|
448
|
-
if (typeof resolved.default === "function") return resolved.default();
|
|
467
|
+
if (typeof resolved.default === "function") return resolved.default(...args);
|
|
449
468
|
return resolved;
|
|
450
469
|
};
|
|
451
470
|
|
|
@@ -462,19 +481,17 @@ const unwrap = async (module) => {
|
|
|
462
481
|
* export default defineConfig();
|
|
463
482
|
*/
|
|
464
483
|
const defineConfig = async ({ astro = false, autoDetect = true, gitignore = false, ignores = [], jest = false, nextjs = false, overrides = [], playwright = false, react = false, storybook = false, tanstackQuery = false, testingLibrary = false, typescript = false, vitest = false } = {}, ...moreOverrides) => {
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
const
|
|
475
|
-
const
|
|
476
|
-
const isJestEnabled = getFlag(jest, hasJest);
|
|
477
|
-
const isVitestEnabled = getFlag(vitest, hasVitest);
|
|
484
|
+
const featured = createFeatured(autoDetect);
|
|
485
|
+
const isTypescriptEnabled = featured(typescript, hasTypescript);
|
|
486
|
+
const isReactEnabled = featured(react, hasReact);
|
|
487
|
+
const isAstroEnabled = featured(astro, hasAstro);
|
|
488
|
+
const isTanstackQueryEnabled = featured(tanstackQuery, hasReactQuery);
|
|
489
|
+
const isTestingLibraryEnabled = featured(testingLibrary, hasTestingLibrary);
|
|
490
|
+
const isPlaywrightEnabled = featured(playwright, hasPlaywright);
|
|
491
|
+
const isStorybookEnabled = featured(storybook, hasStorybook);
|
|
492
|
+
const isNextjsEnabled = featured(nextjs, hasNext);
|
|
493
|
+
const isJestEnabled = featured(jest, hasJest);
|
|
494
|
+
const isVitestEnabled = featured(vitest, hasVitest);
|
|
478
495
|
const baseConfigs = [
|
|
479
496
|
javascriptConfig(),
|
|
480
497
|
perfectionistConfig(),
|
|
@@ -487,16 +504,16 @@ const defineConfig = async ({ astro = false, autoDetect = true, gitignore = fals
|
|
|
487
504
|
stylisticConfig()
|
|
488
505
|
];
|
|
489
506
|
const featureConfigs = await Promise.all([
|
|
490
|
-
isTypescriptEnabled && unwrap(import("./typescript-
|
|
491
|
-
isReactEnabled && unwrap(import("./react-
|
|
492
|
-
isTanstackQueryEnabled && unwrap(import("./tanstack-query-
|
|
493
|
-
isAstroEnabled && unwrap(import("./astro-
|
|
494
|
-
isJestEnabled && unwrap(import("./jest-
|
|
495
|
-
isVitestEnabled && unwrap(import("./vitest-
|
|
496
|
-
isTestingLibraryEnabled && unwrap(import("./testing-library-
|
|
497
|
-
isPlaywrightEnabled && unwrap(import("./playwright-
|
|
507
|
+
isTypescriptEnabled && unwrap(import("./typescript-CMkBsIGI.mjs")),
|
|
508
|
+
isReactEnabled && unwrap(import("./react-DY8zODCu.mjs")),
|
|
509
|
+
isTanstackQueryEnabled && unwrap(import("./tanstack-query-DG6a41GH.mjs")),
|
|
510
|
+
isAstroEnabled && unwrap(import("./astro-DNtOkeq5.mjs")),
|
|
511
|
+
isJestEnabled && unwrap(import("./jest-DgTHyrfz.mjs")),
|
|
512
|
+
isVitestEnabled && unwrap(import("./vitest-C4QXivmM.mjs"), vitest),
|
|
513
|
+
isTestingLibraryEnabled && unwrap(import("./testing-library-oE675dT3.mjs")),
|
|
514
|
+
isPlaywrightEnabled && unwrap(import("./playwright-CM4et1Wx.mjs")),
|
|
498
515
|
isStorybookEnabled && unwrap(import("./storybook-CyxpG33Q.mjs")),
|
|
499
|
-
isNextjsEnabled && unwrap(import("./nextjs-
|
|
516
|
+
isNextjsEnabled && unwrap(import("./nextjs-VPeisXpq.mjs"))
|
|
500
517
|
]);
|
|
501
518
|
return [
|
|
502
519
|
...gitignore ? [gitignoreConfig({ strict: false })] : [],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as GLOB_TSX, o as GLOB_JSX } from "./globs-
|
|
1
|
+
import { d as GLOB_TSX, o as GLOB_JSX } from "./globs-uKx5b8lV.mjs";
|
|
2
2
|
import { l as hasTypescript, r as hasNext, u as hasVite } from "./has-dependency-BreXO1rF.mjs";
|
|
3
3
|
import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
|
|
4
4
|
import { t as upwarn } from "./upwarn-BWFMaOyK.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { l as GLOB_TESTS, r as GLOB_E2E } from "./globs-
|
|
1
|
+
import { f as GLOB_TYPE_TESTS, l as GLOB_TESTS, r as GLOB_E2E } from "./globs-uKx5b8lV.mjs";
|
|
2
2
|
import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/rules/vitest.ts
|
|
5
|
-
const vitestRules = async () => {
|
|
5
|
+
const vitestRules = async (options) => {
|
|
6
6
|
return {
|
|
7
7
|
...(await interopDefault(import("@vitest/eslint-plugin"))).configs.recommended.rules,
|
|
8
8
|
"vitest/consistent-each-for": ["error", {
|
|
@@ -21,6 +21,7 @@ const vitestRules = async () => {
|
|
|
21
21
|
"vitest/no-conditional-in-test": "error",
|
|
22
22
|
"vitest/no-duplicate-hooks": "error",
|
|
23
23
|
"vitest/no-hooks": "off",
|
|
24
|
+
"vitest/no-importing-vitest-globals": options?.globals === "implicit" ? "error" : "off",
|
|
24
25
|
"vitest/no-large-snapshots": "off",
|
|
25
26
|
"vitest/no-restricted-matchers": "off",
|
|
26
27
|
"vitest/no-restricted-vi-methods": "off",
|
|
@@ -39,6 +40,7 @@ const vitestRules = async () => {
|
|
|
39
40
|
"vitest/prefer-expect-type-of": "error",
|
|
40
41
|
"vitest/prefer-hooks-in-order": "error",
|
|
41
42
|
"vitest/prefer-hooks-on-top": "error",
|
|
43
|
+
"vitest/prefer-importing-vitest-globals": options?.globals === "explicit" ? "error" : "off",
|
|
42
44
|
"vitest/prefer-lowercase-title": "off",
|
|
43
45
|
"vitest/prefer-mock-promise-shorthand": "error",
|
|
44
46
|
"vitest/prefer-snapshot-hint": "error",
|
|
@@ -59,15 +61,31 @@ const vitestRules = async () => {
|
|
|
59
61
|
};
|
|
60
62
|
};
|
|
61
63
|
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/utils/extract-options.ts
|
|
66
|
+
/**
|
|
67
|
+
* A simple utility to derive options for configurations when one option is a boolean.
|
|
68
|
+
*
|
|
69
|
+
* @param options - The options to derive.
|
|
70
|
+
*
|
|
71
|
+
* @returns The extracted options or `undefined` if the input was a boolean.
|
|
72
|
+
*/
|
|
73
|
+
const extractOptions = (options) => {
|
|
74
|
+
if (typeof options !== "boolean") return options;
|
|
75
|
+
};
|
|
76
|
+
|
|
62
77
|
//#endregion
|
|
63
78
|
//#region src/configs/vitest.ts
|
|
64
|
-
async function vitestConfig() {
|
|
79
|
+
async function vitestConfig(options) {
|
|
80
|
+
const vitestPlugin = await interopDefault(import("@vitest/eslint-plugin"));
|
|
81
|
+
const extractedOptions = extractOptions(options);
|
|
65
82
|
return [{
|
|
66
|
-
files: GLOB_TESTS,
|
|
83
|
+
files: [...GLOB_TESTS, ...extractedOptions?.typecheck ? GLOB_TYPE_TESTS : []],
|
|
67
84
|
ignores: GLOB_E2E,
|
|
68
|
-
...
|
|
85
|
+
...vitestPlugin.configs.recommended,
|
|
69
86
|
name: "jimmy.codes/vitest",
|
|
70
|
-
rules: await vitestRules()
|
|
87
|
+
rules: await vitestRules(extractedOptions),
|
|
88
|
+
settings: { vitest: { typecheck: extractedOptions?.typecheck ?? false } }
|
|
71
89
|
}];
|
|
72
90
|
}
|
|
73
91
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jimmy.codes/eslint-config",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.23.0",
|
|
4
4
|
"description": "A simple, modern ESLint config that covers most use cases.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
"eslint-plugin-perfectionist": "^4.15.1",
|
|
64
64
|
"eslint-plugin-playwright": "^2.3.0",
|
|
65
65
|
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
|
66
|
-
"eslint-plugin-react-dom": "^2.3.
|
|
66
|
+
"eslint-plugin-react-dom": "^2.3.9",
|
|
67
67
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
68
|
-
"eslint-plugin-react-hooks-extra": "^2.3.
|
|
69
|
-
"eslint-plugin-react-naming-convention": "^2.3.
|
|
68
|
+
"eslint-plugin-react-hooks-extra": "^2.3.9",
|
|
69
|
+
"eslint-plugin-react-naming-convention": "^2.3.9",
|
|
70
70
|
"eslint-plugin-react-refresh": "0.4.24",
|
|
71
|
-
"eslint-plugin-react-web-api": "^2.3.
|
|
72
|
-
"eslint-plugin-react-x": "^2.3.
|
|
71
|
+
"eslint-plugin-react-web-api": "^2.3.9",
|
|
72
|
+
"eslint-plugin-react-x": "^2.3.9",
|
|
73
73
|
"eslint-plugin-regexp": "^2.10.0",
|
|
74
74
|
"eslint-plugin-storybook": "0.12.0",
|
|
75
75
|
"eslint-plugin-testing-library": "^7.13.5",
|