@kazupon/eslint-config 0.14.0 → 0.15.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 CHANGED
@@ -20,6 +20,7 @@ ESLint config for @kazupon
20
20
  - `vue`
21
21
  - `react`
22
22
  - `svelte`
23
+ - `vitest`
23
24
  - `jsonc`
24
25
  - `yml`
25
26
  - `toml`
@@ -123,6 +124,7 @@ The following built-in configurations are supported:
123
124
  | `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
124
125
  | `react` | [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), [`eslint-plugin-react-refresh`](https://www.npmjs.com/package/eslint-plugin-react-refresh) | yes |
125
126
  | `svelte` | [`eslint-plugin-svelte`](https://www.npmjs.com/package/eslint-plugin-svelte) | yes |
127
+ | `vitest` | [`@vitest/eslint-plugin`](https://www.npmjs.com/package/@vitest/eslint-plugin) | yes |
126
128
  | `jsonc` | [`eslint-plugin-jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) | yes |
127
129
  | `yml` | [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml) | yes |
128
130
  | `toml` | [`eslint-plugin-toml`](https://www.npmjs.com/package/eslint-plugin-toml) | yes |
package/dist/config.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
2
2
  import type { Linter } from 'eslint';
3
- import type { Awaitable } from './types';
3
+ import type { Awaitable } from '@kazupon/jts-utils/types';
4
4
  /**
5
5
  * define eslint configurations
6
6
  * @param {Awaitable<Linter.Config | Linter.Config[]>[]} configs eslint flat configurations
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
2
2
  import type { Linter } from 'eslint';
3
- import type { Awaitable } from './types';
3
+ import type { Awaitable } from '@kazupon/jts-utils/types';
4
4
  /**
5
5
  * define eslint configurations
6
6
  * @param {Awaitable<Linter.Config | Linter.Config[]>[]} configs eslint flat configurations
@@ -12,3 +12,4 @@ export * from './yml';
12
12
  export * from './vue';
13
13
  export * from './react';
14
14
  export * from './svelte';
15
+ export * from './vitest';
@@ -12,3 +12,4 @@ export * from './yml';
12
12
  export * from './vue';
13
13
  export * from './react';
14
14
  export * from './svelte';
15
+ export * from './vitest';
@@ -0,0 +1,22 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions, VitestRules } from '../types';
3
+ /**
4
+ * eslint vitest configuration options
5
+ */
6
+ export interface VitestOptions {
7
+ /**
8
+ * use type testing
9
+ * @description about type testing, see https://vitest.dev/guide/testing-types,
10
+ * and about eslint config, see https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#enabling-with-type-testing
11
+ * @default false
12
+ */
13
+ typeTesting?: boolean;
14
+ }
15
+ /**
16
+ * `@vitest/eslint-plugin` and overrides configuration options
17
+ * @param {VitestOptions & OverridesOptions} options
18
+ * eslint vitest configuration options
19
+ * @returns {Promise<Linter.Config[]>}
20
+ * eslint flat configurations with `@vitest/eslint-plugin` and overrides
21
+ */
22
+ export declare function vitest(options?: VitestOptions & OverridesOptions<VitestRules>): Promise<Linter.Config[]>;
@@ -0,0 +1,22 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions, VitestRules } from '../types';
3
+ /**
4
+ * eslint vitest configuration options
5
+ */
6
+ export interface VitestOptions {
7
+ /**
8
+ * use type testing
9
+ * @description about type testing, see https://vitest.dev/guide/testing-types,
10
+ * and about eslint config, see https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#enabling-with-type-testing
11
+ * @default false
12
+ */
13
+ typeTesting?: boolean;
14
+ }
15
+ /**
16
+ * `@vitest/eslint-plugin` and overrides configuration options
17
+ * @param {VitestOptions & OverridesOptions} options
18
+ * eslint vitest configuration options
19
+ * @returns {Promise<Linter.Config[]>}
20
+ * eslint flat configurations with `@vitest/eslint-plugin` and overrides
21
+ */
22
+ export declare function vitest(options?: VitestOptions & OverridesOptions<VitestRules>): Promise<Linter.Config[]>;
package/dist/globs.d.cts CHANGED
@@ -9,3 +9,5 @@ export declare const GLOB_YAML = "**/*.y?(a)ml";
9
9
  export declare const GLOB_TOML = "**/*.toml";
10
10
  export declare const GLOB_VUE = "**/*.vue";
11
11
  export declare const GLOB_SVELTE = "**/*.svelte";
12
+ export declare const GLOB_TESTS: string[];
13
+ export declare const GLOB_TESTS_TYPE: string[];
package/dist/globs.d.ts CHANGED
@@ -9,3 +9,5 @@ export declare const GLOB_YAML = "**/*.y?(a)ml";
9
9
  export declare const GLOB_TOML = "**/*.toml";
10
10
  export declare const GLOB_VUE = "**/*.vue";
11
11
  export declare const GLOB_SVELTE = "**/*.svelte";
12
+ export declare const GLOB_TESTS: string[];
13
+ export declare const GLOB_TESTS_TYPE: string[];
package/dist/index.cjs CHANGED
@@ -44,13 +44,19 @@ const GLOB_YAML = "**/*.y?(a)ml";
44
44
  const GLOB_TOML = "**/*.toml";
45
45
  const GLOB_VUE = "**/*.vue";
46
46
  const GLOB_SVELTE = "**/*.svelte";
47
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
48
+ const GLOB_TESTS = [`**/test/**/*.${GLOB_SRC_EXT}`, `**/tests/**/*.${GLOB_SRC_EXT}`, `**/spec/**/*.${GLOB_SRC_EXT}`, `**/specs/**/*.${GLOB_SRC_EXT}`, `**/e2e/**/*.${GLOB_SRC_EXT}`, `**/__tests__/**/*.${GLOB_SRC_EXT}`, `**/__test__/**/*.${GLOB_SRC_EXT}`, `**/*.spec.${GLOB_SRC_EXT}`, `**/*.test.${GLOB_SRC_EXT}`];
49
+ const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
47
50
 
48
51
  //#endregion
49
- //#region src/utils.ts
52
+ //#region node_modules/.pnpm/@kazupon+jts-utils@0.2.0/node_modules/@kazupon/jts-utils/dist/module/index.mjs
50
53
  async function interopDefault(mod) {
51
54
  const resolved = await mod;
52
55
  return resolved.default || resolved;
53
56
  }
57
+
58
+ //#endregion
59
+ //#region src/utils.ts
54
60
  async function loadPlugin(name) {
55
61
  const mod = await import(name).catch((error) => {
56
62
  console.error(error);
@@ -424,6 +430,37 @@ async function svelte(options = {}) {
424
430
  return [...svelte$1.configs["flat/recommended"], customConfig];
425
431
  }
426
432
 
433
+ //#endregion
434
+ //#region src/configs/vitest.ts
435
+ async function vitest(options = {}) {
436
+ const { rules: overrideRules = {}, files: overrideFiles = [] } = options;
437
+ const typeTesting = !!options.typeTesting;
438
+ const vitest$1 = await loadPlugin("@vitest/eslint-plugin");
439
+ const configs = [];
440
+ const base = {
441
+ files: GLOB_TESTS,
442
+ ...vitest$1.configs["recommended"]
443
+ };
444
+ if (base.name == undefined) {
445
+ base.name = "@vitest/eslint-plugin";
446
+ }
447
+ if (typeTesting) {
448
+ base.files = [...base.files, ...GLOB_TESTS_TYPE];
449
+ base.settings = { vitest: { typecheck: true } };
450
+ base.languageOptions = { globals: { ...vitest$1.environments.env.globals } };
451
+ }
452
+ configs.push(base);
453
+ const custom = {
454
+ name: "@kazupon/vitest",
455
+ rules: { ...overrideRules }
456
+ };
457
+ if (overrideFiles.length > 0) {
458
+ custom.files = overrideFiles;
459
+ }
460
+ configs.push(custom);
461
+ return configs;
462
+ }
463
+
427
464
  //#endregion
428
465
  Object.defineProperty(exports, 'comments', {
429
466
  enumerable: true,
@@ -503,6 +540,12 @@ Object.defineProperty(exports, 'unicorn', {
503
540
  return unicorn;
504
541
  }
505
542
  });
543
+ Object.defineProperty(exports, 'vitest', {
544
+ enumerable: true,
545
+ get: function () {
546
+ return vitest;
547
+ }
548
+ });
506
549
  Object.defineProperty(exports, 'vue', {
507
550
  enumerable: true,
508
551
  get: function () {
package/dist/index.js CHANGED
@@ -20,13 +20,19 @@ const GLOB_YAML = "**/*.y?(a)ml";
20
20
  const GLOB_TOML = "**/*.toml";
21
21
  const GLOB_VUE = "**/*.vue";
22
22
  const GLOB_SVELTE = "**/*.svelte";
23
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
24
+ const GLOB_TESTS = [`**/test/**/*.${GLOB_SRC_EXT}`, `**/tests/**/*.${GLOB_SRC_EXT}`, `**/spec/**/*.${GLOB_SRC_EXT}`, `**/specs/**/*.${GLOB_SRC_EXT}`, `**/e2e/**/*.${GLOB_SRC_EXT}`, `**/__tests__/**/*.${GLOB_SRC_EXT}`, `**/__test__/**/*.${GLOB_SRC_EXT}`, `**/*.spec.${GLOB_SRC_EXT}`, `**/*.test.${GLOB_SRC_EXT}`];
25
+ const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
23
26
 
24
27
  //#endregion
25
- //#region src/utils.ts
28
+ //#region node_modules/.pnpm/@kazupon+jts-utils@0.2.0/node_modules/@kazupon/jts-utils/dist/module/index.mjs
26
29
  async function interopDefault(mod) {
27
30
  const resolved = await mod;
28
31
  return resolved.default || resolved;
29
32
  }
33
+
34
+ //#endregion
35
+ //#region src/utils.ts
30
36
  async function loadPlugin(name) {
31
37
  const mod = await import(name).catch((error) => {
32
38
  console.error(error);
@@ -401,4 +407,35 @@ async function svelte(options = {}) {
401
407
  }
402
408
 
403
409
  //#endregion
404
- export { comments, defineConfig, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vue, yaml, yml };
410
+ //#region src/configs/vitest.ts
411
+ async function vitest(options = {}) {
412
+ const { rules: overrideRules = {}, files: overrideFiles = [] } = options;
413
+ const typeTesting = !!options.typeTesting;
414
+ const vitest$1 = await loadPlugin("@vitest/eslint-plugin");
415
+ const configs = [];
416
+ const base = {
417
+ files: GLOB_TESTS,
418
+ ...vitest$1.configs["recommended"]
419
+ };
420
+ if (base.name == undefined) {
421
+ base.name = "@vitest/eslint-plugin";
422
+ }
423
+ if (typeTesting) {
424
+ base.files = [...base.files, ...GLOB_TESTS_TYPE];
425
+ base.settings = { vitest: { typecheck: true } };
426
+ base.languageOptions = { globals: { ...vitest$1.environments.env.globals } };
427
+ }
428
+ configs.push(base);
429
+ const custom = {
430
+ name: "@kazupon/vitest",
431
+ rules: { ...overrideRules }
432
+ };
433
+ if (overrideFiles.length > 0) {
434
+ custom.files = overrideFiles;
435
+ }
436
+ configs.push(custom);
437
+ return configs;
438
+ }
439
+
440
+ //#endregion
441
+ export { comments, defineConfig, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
@@ -10,11 +10,12 @@ import type { SvelteRules } from './svelte';
10
10
  import type { TomlRules } from './toml';
11
11
  import type { TypescriptRules } from './typescript';
12
12
  import type { UnicornRules } from './unicorn';
13
+ import type { VitestRules } from './vitest';
13
14
  import type { VueRules } from './vue';
14
15
  import type { YmlRules } from './yml';
15
16
  declare module 'eslint' {
16
17
  namespace Linter {
17
- interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
18
+ interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
18
19
  }
19
20
  }
20
21
  }
@@ -10,11 +10,12 @@ import type { SvelteRules } from './svelte';
10
10
  import type { TomlRules } from './toml';
11
11
  import type { TypescriptRules } from './typescript';
12
12
  import type { UnicornRules } from './unicorn';
13
+ import type { VitestRules } from './vitest';
13
14
  import type { VueRules } from './vue';
14
15
  import type { YmlRules } from './yml';
15
16
  declare module 'eslint' {
16
17
  namespace Linter {
17
- interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
18
+ interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
18
19
  }
19
20
  }
20
21
  }
@@ -0,0 +1,377 @@
1
+ import type { Linter } from 'eslint';
2
+ export interface VitestRules {
3
+ /**
4
+ * require .spec test file pattern
5
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
6
+ */
7
+ 'vitest/consistent-test-filename'?: Linter.RuleEntry<VitestConsistentTestFilename>;
8
+ /**
9
+ * enforce using test or it but not both
10
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
11
+ */
12
+ 'vitest/consistent-test-it'?: Linter.RuleEntry<VitestConsistentTestIt>;
13
+ /**
14
+ * enforce having expectation in test body
15
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
16
+ */
17
+ 'vitest/expect-expect'?: Linter.RuleEntry<VitestExpectExpect>;
18
+ /**
19
+ * Enforce padding around afterAll blocks
20
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/index.md
21
+ */
22
+ 'vitest/index'?: Linter.RuleEntry<[]>;
23
+ /**
24
+ * enforce a maximum number of expect per test
25
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
26
+ */
27
+ 'vitest/max-expects'?: Linter.RuleEntry<VitestMaxExpects>;
28
+ /**
29
+ * require describe block to be less than set max value or default value
30
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
31
+ */
32
+ 'vitest/max-nested-describe'?: Linter.RuleEntry<VitestMaxNestedDescribe>;
33
+ /**
34
+ * disallow alias methods
35
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
36
+ */
37
+ 'vitest/no-alias-methods'?: Linter.RuleEntry<[]>;
38
+ /**
39
+ * disallow commented out tests
40
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
41
+ */
42
+ 'vitest/no-commented-out-tests'?: Linter.RuleEntry<[]>;
43
+ /**
44
+ * disallow conditional expects
45
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
46
+ */
47
+ 'vitest/no-conditional-expect'?: Linter.RuleEntry<[]>;
48
+ /**
49
+ * disallow conditional tests
50
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
51
+ */
52
+ 'vitest/no-conditional-in-test'?: Linter.RuleEntry<[]>;
53
+ /**
54
+ * disallow conditional tests
55
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md
56
+ */
57
+ 'vitest/no-conditional-tests'?: Linter.RuleEntry<[]>;
58
+ /**
59
+ * disallow disabled tests
60
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
61
+ */
62
+ 'vitest/no-disabled-tests'?: Linter.RuleEntry<[]>;
63
+ /**
64
+ * disallow using a callback in asynchronous tests and hooks
65
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
66
+ * @deprecated
67
+ */
68
+ 'vitest/no-done-callback'?: Linter.RuleEntry<[]>;
69
+ /**
70
+ * disallow duplicate hooks and teardown hooks
71
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
72
+ */
73
+ 'vitest/no-duplicate-hooks'?: Linter.RuleEntry<[]>;
74
+ /**
75
+ * disallow focused tests
76
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
77
+ */
78
+ 'vitest/no-focused-tests'?: Linter.RuleEntry<VitestNoFocusedTests>;
79
+ /**
80
+ * disallow setup and teardown hooks
81
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
82
+ */
83
+ 'vitest/no-hooks'?: Linter.RuleEntry<VitestNoHooks>;
84
+ /**
85
+ * disallow identical titles
86
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
87
+ */
88
+ 'vitest/no-identical-title'?: Linter.RuleEntry<[]>;
89
+ /**
90
+ * disallow importing `node:test`
91
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
92
+ */
93
+ 'vitest/no-import-node-test'?: Linter.RuleEntry<[]>;
94
+ /**
95
+ * disallow string interpolation in snapshots
96
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
97
+ */
98
+ 'vitest/no-interpolation-in-snapshots'?: Linter.RuleEntry<[]>;
99
+ /**
100
+ * disallow large snapshots
101
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
102
+ */
103
+ 'vitest/no-large-snapshots'?: Linter.RuleEntry<VitestNoLargeSnapshots>;
104
+ /**
105
+ * disallow importing from __mocks__ directory
106
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
107
+ */
108
+ 'vitest/no-mocks-import'?: Linter.RuleEntry<[]>;
109
+ /**
110
+ * disallow the use of certain matchers
111
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
112
+ */
113
+ 'vitest/no-restricted-matchers'?: Linter.RuleEntry<VitestNoRestrictedMatchers>;
114
+ /**
115
+ * disallow specific `vi.` methods
116
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md
117
+ */
118
+ 'vitest/no-restricted-vi-methods'?: Linter.RuleEntry<VitestNoRestrictedViMethods>;
119
+ /**
120
+ * disallow using `expect` outside of `it` or `test` blocks
121
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
122
+ */
123
+ 'vitest/no-standalone-expect'?: Linter.RuleEntry<VitestNoStandaloneExpect>;
124
+ /**
125
+ * disallow using `test` as a prefix
126
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
127
+ */
128
+ 'vitest/no-test-prefixes'?: Linter.RuleEntry<[]>;
129
+ /**
130
+ * disallow return statements in tests
131
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
132
+ */
133
+ 'vitest/no-test-return-statement'?: Linter.RuleEntry<[]>;
134
+ /**
135
+ * enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`
136
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
137
+ */
138
+ 'vitest/prefer-called-with'?: Linter.RuleEntry<[]>;
139
+ /**
140
+ * enforce using the built-in comparison matchers
141
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
142
+ */
143
+ 'vitest/prefer-comparison-matcher'?: Linter.RuleEntry<[]>;
144
+ /**
145
+ * enforce using `each` rather than manual loops
146
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
147
+ */
148
+ 'vitest/prefer-each'?: Linter.RuleEntry<[]>;
149
+ /**
150
+ * enforce using the built-in quality matchers
151
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
152
+ */
153
+ 'vitest/prefer-equality-matcher'?: Linter.RuleEntry<[]>;
154
+ /**
155
+ * enforce using expect assertions instead of callbacks
156
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
157
+ */
158
+ 'vitest/prefer-expect-assertions'?: Linter.RuleEntry<VitestPreferExpectAssertions>;
159
+ /**
160
+ * enforce using `expect().resolves` over `expect(await ...)` syntax
161
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
162
+ */
163
+ 'vitest/prefer-expect-resolves'?: Linter.RuleEntry<[]>;
164
+ /**
165
+ * enforce having hooks in consistent order
166
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
167
+ */
168
+ 'vitest/prefer-hooks-in-order'?: Linter.RuleEntry<[]>;
169
+ /**
170
+ * enforce having hooks before any test cases
171
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
172
+ */
173
+ 'vitest/prefer-hooks-on-top'?: Linter.RuleEntry<[]>;
174
+ /**
175
+ * enforce lowercase titles
176
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
177
+ */
178
+ 'vitest/prefer-lowercase-title'?: Linter.RuleEntry<VitestPreferLowercaseTitle>;
179
+ /**
180
+ * enforce mock resolved/rejected shorthands for promises
181
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
182
+ */
183
+ 'vitest/prefer-mock-promise-shorthand'?: Linter.RuleEntry<[]>;
184
+ /**
185
+ * enforce including a hint with external snapshots
186
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
187
+ */
188
+ 'vitest/prefer-snapshot-hint'?: Linter.RuleEntry<VitestPreferSnapshotHint>;
189
+ /**
190
+ * enforce using `vi.spyOn`
191
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
192
+ */
193
+ 'vitest/prefer-spy-on'?: Linter.RuleEntry<[]>;
194
+ /**
195
+ * enforce strict equal over equal
196
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
197
+ */
198
+ 'vitest/prefer-strict-equal'?: Linter.RuleEntry<[]>;
199
+ /**
200
+ * enforce using toBe()
201
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
202
+ */
203
+ 'vitest/prefer-to-be'?: Linter.RuleEntry<[]>;
204
+ /**
205
+ * enforce using toBeFalsy()
206
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md
207
+ */
208
+ 'vitest/prefer-to-be-falsy'?: Linter.RuleEntry<[]>;
209
+ /**
210
+ * enforce using toBeObject()
211
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md
212
+ */
213
+ 'vitest/prefer-to-be-object'?: Linter.RuleEntry<[]>;
214
+ /**
215
+ * enforce using `toBeTruthy`
216
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md
217
+ */
218
+ 'vitest/prefer-to-be-truthy'?: Linter.RuleEntry<[]>;
219
+ /**
220
+ * enforce using toContain()
221
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
222
+ */
223
+ 'vitest/prefer-to-contain'?: Linter.RuleEntry<[]>;
224
+ /**
225
+ * enforce using toHaveLength()
226
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
227
+ */
228
+ 'vitest/prefer-to-have-length'?: Linter.RuleEntry<[]>;
229
+ /**
230
+ * enforce using `test.todo`
231
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
232
+ */
233
+ 'vitest/prefer-todo'?: Linter.RuleEntry<[]>;
234
+ /**
235
+ * require setup and teardown to be within a hook
236
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
237
+ */
238
+ 'vitest/require-hook'?: Linter.RuleEntry<VitestRequireHook>;
239
+ /**
240
+ * require local Test Context for concurrent snapshot tests
241
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
242
+ */
243
+ 'vitest/require-local-test-context-for-concurrent-snapshots'?: Linter.RuleEntry<[]>;
244
+ /**
245
+ * require toThrow() to be called with an error message
246
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
247
+ */
248
+ 'vitest/require-to-throw-message'?: Linter.RuleEntry<[]>;
249
+ /**
250
+ * enforce that all tests are in a top-level describe
251
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
252
+ */
253
+ 'vitest/require-top-level-describe'?: Linter.RuleEntry<VitestRequireTopLevelDescribe>;
254
+ /**
255
+ * enforce valid describe callback
256
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
257
+ */
258
+ 'vitest/valid-describe-callback'?: Linter.RuleEntry<[]>;
259
+ /**
260
+ * enforce valid `expect()` usage
261
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
262
+ */
263
+ 'vitest/valid-expect'?: Linter.RuleEntry<VitestValidExpect>;
264
+ /**
265
+ * enforce valid titles
266
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
267
+ */
268
+ 'vitest/valid-title'?: Linter.RuleEntry<VitestValidTitle>;
269
+ }
270
+ type VitestConsistentTestFilename = [] | [
271
+ {
272
+ pattern?: string;
273
+ allTestPattern?: string;
274
+ }
275
+ ];
276
+ type VitestConsistentTestIt = [] | [
277
+ {
278
+ fn?: ("test" | "it");
279
+ withinDescribe?: ("test" | "it");
280
+ }
281
+ ];
282
+ type VitestExpectExpect = [] | [
283
+ {
284
+ assertFunctionNames?: [] | [string];
285
+ additionalTestBlockFunctions?: string[];
286
+ }
287
+ ];
288
+ type VitestMaxExpects = [] | [
289
+ {
290
+ max?: number;
291
+ }
292
+ ];
293
+ type VitestMaxNestedDescribe = [] | [
294
+ {
295
+ max?: number;
296
+ }
297
+ ];
298
+ type VitestNoFocusedTests = [] | [
299
+ {
300
+ fixable?: boolean;
301
+ }
302
+ ];
303
+ type VitestNoHooks = [] | [
304
+ {
305
+ allow?: unknown[];
306
+ }
307
+ ];
308
+ type VitestNoLargeSnapshots = [] | [
309
+ {
310
+ maxSize?: number;
311
+ inlineMaxSize?: number;
312
+ allowedSnapshots?: {
313
+ [k: string]: unknown[] | undefined;
314
+ };
315
+ }
316
+ ];
317
+ type VitestNoRestrictedMatchers = [] | [
318
+ {
319
+ [k: string]: (string | null) | undefined;
320
+ }
321
+ ];
322
+ type VitestNoRestrictedViMethods = [] | [
323
+ {
324
+ [k: string]: (string | null) | undefined;
325
+ }
326
+ ];
327
+ type VitestNoStandaloneExpect = [] | [
328
+ {
329
+ additionaltestblockfunctions?: string[];
330
+ [k: string]: unknown | undefined;
331
+ }
332
+ ];
333
+ type VitestPreferExpectAssertions = [] | [
334
+ {
335
+ onlyFunctionsWithAsyncKeyword?: boolean;
336
+ onlyFunctionsWithExpectInLoop?: boolean;
337
+ onlyFunctionsWithExpectInCallback?: boolean;
338
+ }
339
+ ];
340
+ type VitestPreferLowercaseTitle = [] | [
341
+ {
342
+ ignore?: ("describe" | "test" | "it")[];
343
+ allowedPrefixes?: string[];
344
+ ignoreTopLevelDescribe?: boolean;
345
+ lowercaseFirstCharacterOnly?: boolean;
346
+ }
347
+ ];
348
+ type VitestPreferSnapshotHint = [] | [("always" | "multi")];
349
+ type VitestRequireHook = [] | [
350
+ {
351
+ allowedFunctionCalls?: string[];
352
+ }
353
+ ];
354
+ type VitestRequireTopLevelDescribe = [] | [
355
+ {
356
+ maxNumberOfTopLevelDescribes?: number;
357
+ }
358
+ ];
359
+ type VitestValidExpect = [] | [
360
+ {
361
+ alwaysAwait?: boolean;
362
+ asyncMatchers?: string[];
363
+ minArgs?: number;
364
+ maxArgs?: number;
365
+ }
366
+ ];
367
+ type VitestValidTitle = [] | [
368
+ {
369
+ ignoreTypeOfDescribeName?: boolean;
370
+ allowArguments?: boolean;
371
+ disallowedWords?: string[];
372
+ [k: string]: (string | [string] | [string, string] | {
373
+ [k: string]: (string | [string] | [string, string]) | undefined;
374
+ });
375
+ }
376
+ ];
377
+ export {};
@@ -0,0 +1,377 @@
1
+ import type { Linter } from 'eslint';
2
+ export interface VitestRules {
3
+ /**
4
+ * require .spec test file pattern
5
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
6
+ */
7
+ 'vitest/consistent-test-filename'?: Linter.RuleEntry<VitestConsistentTestFilename>;
8
+ /**
9
+ * enforce using test or it but not both
10
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
11
+ */
12
+ 'vitest/consistent-test-it'?: Linter.RuleEntry<VitestConsistentTestIt>;
13
+ /**
14
+ * enforce having expectation in test body
15
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
16
+ */
17
+ 'vitest/expect-expect'?: Linter.RuleEntry<VitestExpectExpect>;
18
+ /**
19
+ * Enforce padding around afterAll blocks
20
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/index.md
21
+ */
22
+ 'vitest/index'?: Linter.RuleEntry<[]>;
23
+ /**
24
+ * enforce a maximum number of expect per test
25
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
26
+ */
27
+ 'vitest/max-expects'?: Linter.RuleEntry<VitestMaxExpects>;
28
+ /**
29
+ * require describe block to be less than set max value or default value
30
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
31
+ */
32
+ 'vitest/max-nested-describe'?: Linter.RuleEntry<VitestMaxNestedDescribe>;
33
+ /**
34
+ * disallow alias methods
35
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
36
+ */
37
+ 'vitest/no-alias-methods'?: Linter.RuleEntry<[]>;
38
+ /**
39
+ * disallow commented out tests
40
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
41
+ */
42
+ 'vitest/no-commented-out-tests'?: Linter.RuleEntry<[]>;
43
+ /**
44
+ * disallow conditional expects
45
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
46
+ */
47
+ 'vitest/no-conditional-expect'?: Linter.RuleEntry<[]>;
48
+ /**
49
+ * disallow conditional tests
50
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
51
+ */
52
+ 'vitest/no-conditional-in-test'?: Linter.RuleEntry<[]>;
53
+ /**
54
+ * disallow conditional tests
55
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md
56
+ */
57
+ 'vitest/no-conditional-tests'?: Linter.RuleEntry<[]>;
58
+ /**
59
+ * disallow disabled tests
60
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
61
+ */
62
+ 'vitest/no-disabled-tests'?: Linter.RuleEntry<[]>;
63
+ /**
64
+ * disallow using a callback in asynchronous tests and hooks
65
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
66
+ * @deprecated
67
+ */
68
+ 'vitest/no-done-callback'?: Linter.RuleEntry<[]>;
69
+ /**
70
+ * disallow duplicate hooks and teardown hooks
71
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
72
+ */
73
+ 'vitest/no-duplicate-hooks'?: Linter.RuleEntry<[]>;
74
+ /**
75
+ * disallow focused tests
76
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
77
+ */
78
+ 'vitest/no-focused-tests'?: Linter.RuleEntry<VitestNoFocusedTests>;
79
+ /**
80
+ * disallow setup and teardown hooks
81
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
82
+ */
83
+ 'vitest/no-hooks'?: Linter.RuleEntry<VitestNoHooks>;
84
+ /**
85
+ * disallow identical titles
86
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
87
+ */
88
+ 'vitest/no-identical-title'?: Linter.RuleEntry<[]>;
89
+ /**
90
+ * disallow importing `node:test`
91
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
92
+ */
93
+ 'vitest/no-import-node-test'?: Linter.RuleEntry<[]>;
94
+ /**
95
+ * disallow string interpolation in snapshots
96
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
97
+ */
98
+ 'vitest/no-interpolation-in-snapshots'?: Linter.RuleEntry<[]>;
99
+ /**
100
+ * disallow large snapshots
101
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
102
+ */
103
+ 'vitest/no-large-snapshots'?: Linter.RuleEntry<VitestNoLargeSnapshots>;
104
+ /**
105
+ * disallow importing from __mocks__ directory
106
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
107
+ */
108
+ 'vitest/no-mocks-import'?: Linter.RuleEntry<[]>;
109
+ /**
110
+ * disallow the use of certain matchers
111
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
112
+ */
113
+ 'vitest/no-restricted-matchers'?: Linter.RuleEntry<VitestNoRestrictedMatchers>;
114
+ /**
115
+ * disallow specific `vi.` methods
116
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md
117
+ */
118
+ 'vitest/no-restricted-vi-methods'?: Linter.RuleEntry<VitestNoRestrictedViMethods>;
119
+ /**
120
+ * disallow using `expect` outside of `it` or `test` blocks
121
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
122
+ */
123
+ 'vitest/no-standalone-expect'?: Linter.RuleEntry<VitestNoStandaloneExpect>;
124
+ /**
125
+ * disallow using `test` as a prefix
126
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
127
+ */
128
+ 'vitest/no-test-prefixes'?: Linter.RuleEntry<[]>;
129
+ /**
130
+ * disallow return statements in tests
131
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
132
+ */
133
+ 'vitest/no-test-return-statement'?: Linter.RuleEntry<[]>;
134
+ /**
135
+ * enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`
136
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
137
+ */
138
+ 'vitest/prefer-called-with'?: Linter.RuleEntry<[]>;
139
+ /**
140
+ * enforce using the built-in comparison matchers
141
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
142
+ */
143
+ 'vitest/prefer-comparison-matcher'?: Linter.RuleEntry<[]>;
144
+ /**
145
+ * enforce using `each` rather than manual loops
146
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
147
+ */
148
+ 'vitest/prefer-each'?: Linter.RuleEntry<[]>;
149
+ /**
150
+ * enforce using the built-in quality matchers
151
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
152
+ */
153
+ 'vitest/prefer-equality-matcher'?: Linter.RuleEntry<[]>;
154
+ /**
155
+ * enforce using expect assertions instead of callbacks
156
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
157
+ */
158
+ 'vitest/prefer-expect-assertions'?: Linter.RuleEntry<VitestPreferExpectAssertions>;
159
+ /**
160
+ * enforce using `expect().resolves` over `expect(await ...)` syntax
161
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
162
+ */
163
+ 'vitest/prefer-expect-resolves'?: Linter.RuleEntry<[]>;
164
+ /**
165
+ * enforce having hooks in consistent order
166
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
167
+ */
168
+ 'vitest/prefer-hooks-in-order'?: Linter.RuleEntry<[]>;
169
+ /**
170
+ * enforce having hooks before any test cases
171
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
172
+ */
173
+ 'vitest/prefer-hooks-on-top'?: Linter.RuleEntry<[]>;
174
+ /**
175
+ * enforce lowercase titles
176
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
177
+ */
178
+ 'vitest/prefer-lowercase-title'?: Linter.RuleEntry<VitestPreferLowercaseTitle>;
179
+ /**
180
+ * enforce mock resolved/rejected shorthands for promises
181
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
182
+ */
183
+ 'vitest/prefer-mock-promise-shorthand'?: Linter.RuleEntry<[]>;
184
+ /**
185
+ * enforce including a hint with external snapshots
186
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
187
+ */
188
+ 'vitest/prefer-snapshot-hint'?: Linter.RuleEntry<VitestPreferSnapshotHint>;
189
+ /**
190
+ * enforce using `vi.spyOn`
191
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
192
+ */
193
+ 'vitest/prefer-spy-on'?: Linter.RuleEntry<[]>;
194
+ /**
195
+ * enforce strict equal over equal
196
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
197
+ */
198
+ 'vitest/prefer-strict-equal'?: Linter.RuleEntry<[]>;
199
+ /**
200
+ * enforce using toBe()
201
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
202
+ */
203
+ 'vitest/prefer-to-be'?: Linter.RuleEntry<[]>;
204
+ /**
205
+ * enforce using toBeFalsy()
206
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md
207
+ */
208
+ 'vitest/prefer-to-be-falsy'?: Linter.RuleEntry<[]>;
209
+ /**
210
+ * enforce using toBeObject()
211
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md
212
+ */
213
+ 'vitest/prefer-to-be-object'?: Linter.RuleEntry<[]>;
214
+ /**
215
+ * enforce using `toBeTruthy`
216
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md
217
+ */
218
+ 'vitest/prefer-to-be-truthy'?: Linter.RuleEntry<[]>;
219
+ /**
220
+ * enforce using toContain()
221
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
222
+ */
223
+ 'vitest/prefer-to-contain'?: Linter.RuleEntry<[]>;
224
+ /**
225
+ * enforce using toHaveLength()
226
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
227
+ */
228
+ 'vitest/prefer-to-have-length'?: Linter.RuleEntry<[]>;
229
+ /**
230
+ * enforce using `test.todo`
231
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
232
+ */
233
+ 'vitest/prefer-todo'?: Linter.RuleEntry<[]>;
234
+ /**
235
+ * require setup and teardown to be within a hook
236
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
237
+ */
238
+ 'vitest/require-hook'?: Linter.RuleEntry<VitestRequireHook>;
239
+ /**
240
+ * require local Test Context for concurrent snapshot tests
241
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
242
+ */
243
+ 'vitest/require-local-test-context-for-concurrent-snapshots'?: Linter.RuleEntry<[]>;
244
+ /**
245
+ * require toThrow() to be called with an error message
246
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
247
+ */
248
+ 'vitest/require-to-throw-message'?: Linter.RuleEntry<[]>;
249
+ /**
250
+ * enforce that all tests are in a top-level describe
251
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
252
+ */
253
+ 'vitest/require-top-level-describe'?: Linter.RuleEntry<VitestRequireTopLevelDescribe>;
254
+ /**
255
+ * enforce valid describe callback
256
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
257
+ */
258
+ 'vitest/valid-describe-callback'?: Linter.RuleEntry<[]>;
259
+ /**
260
+ * enforce valid `expect()` usage
261
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
262
+ */
263
+ 'vitest/valid-expect'?: Linter.RuleEntry<VitestValidExpect>;
264
+ /**
265
+ * enforce valid titles
266
+ * @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
267
+ */
268
+ 'vitest/valid-title'?: Linter.RuleEntry<VitestValidTitle>;
269
+ }
270
+ type VitestConsistentTestFilename = [] | [
271
+ {
272
+ pattern?: string;
273
+ allTestPattern?: string;
274
+ }
275
+ ];
276
+ type VitestConsistentTestIt = [] | [
277
+ {
278
+ fn?: ("test" | "it");
279
+ withinDescribe?: ("test" | "it");
280
+ }
281
+ ];
282
+ type VitestExpectExpect = [] | [
283
+ {
284
+ assertFunctionNames?: [] | [string];
285
+ additionalTestBlockFunctions?: string[];
286
+ }
287
+ ];
288
+ type VitestMaxExpects = [] | [
289
+ {
290
+ max?: number;
291
+ }
292
+ ];
293
+ type VitestMaxNestedDescribe = [] | [
294
+ {
295
+ max?: number;
296
+ }
297
+ ];
298
+ type VitestNoFocusedTests = [] | [
299
+ {
300
+ fixable?: boolean;
301
+ }
302
+ ];
303
+ type VitestNoHooks = [] | [
304
+ {
305
+ allow?: unknown[];
306
+ }
307
+ ];
308
+ type VitestNoLargeSnapshots = [] | [
309
+ {
310
+ maxSize?: number;
311
+ inlineMaxSize?: number;
312
+ allowedSnapshots?: {
313
+ [k: string]: unknown[] | undefined;
314
+ };
315
+ }
316
+ ];
317
+ type VitestNoRestrictedMatchers = [] | [
318
+ {
319
+ [k: string]: (string | null) | undefined;
320
+ }
321
+ ];
322
+ type VitestNoRestrictedViMethods = [] | [
323
+ {
324
+ [k: string]: (string | null) | undefined;
325
+ }
326
+ ];
327
+ type VitestNoStandaloneExpect = [] | [
328
+ {
329
+ additionaltestblockfunctions?: string[];
330
+ [k: string]: unknown | undefined;
331
+ }
332
+ ];
333
+ type VitestPreferExpectAssertions = [] | [
334
+ {
335
+ onlyFunctionsWithAsyncKeyword?: boolean;
336
+ onlyFunctionsWithExpectInLoop?: boolean;
337
+ onlyFunctionsWithExpectInCallback?: boolean;
338
+ }
339
+ ];
340
+ type VitestPreferLowercaseTitle = [] | [
341
+ {
342
+ ignore?: ("describe" | "test" | "it")[];
343
+ allowedPrefixes?: string[];
344
+ ignoreTopLevelDescribe?: boolean;
345
+ lowercaseFirstCharacterOnly?: boolean;
346
+ }
347
+ ];
348
+ type VitestPreferSnapshotHint = [] | [("always" | "multi")];
349
+ type VitestRequireHook = [] | [
350
+ {
351
+ allowedFunctionCalls?: string[];
352
+ }
353
+ ];
354
+ type VitestRequireTopLevelDescribe = [] | [
355
+ {
356
+ maxNumberOfTopLevelDescribes?: number;
357
+ }
358
+ ];
359
+ type VitestValidExpect = [] | [
360
+ {
361
+ alwaysAwait?: boolean;
362
+ asyncMatchers?: string[];
363
+ minArgs?: number;
364
+ maxArgs?: number;
365
+ }
366
+ ];
367
+ type VitestValidTitle = [] | [
368
+ {
369
+ ignoreTypeOfDescribeName?: boolean;
370
+ allowArguments?: boolean;
371
+ disallowedWords?: string[];
372
+ [k: string]: (string | [string] | [string, string] | {
373
+ [k: string]: (string | [string] | [string, string]) | undefined;
374
+ });
375
+ }
376
+ ];
377
+ export {};
@@ -1,4 +1,3 @@
1
- export * from './utils';
2
1
  export * from './overrides';
3
2
  export * from './gens/javascript';
4
3
  export * from './gens/unicorn';
@@ -14,4 +13,5 @@ export * from './gens/jsonc';
14
13
  export * from './gens/yml';
15
14
  export * from './gens/react';
16
15
  export * from './gens/toml';
16
+ export * from './gens/vitest';
17
17
  export * from './gens/eslint';
@@ -1,4 +1,3 @@
1
- export * from './utils';
2
1
  export * from './overrides';
3
2
  export * from './gens/javascript';
4
3
  export * from './gens/unicorn';
@@ -14,4 +13,5 @@ export * from './gens/jsonc';
14
13
  export * from './gens/yml';
15
14
  export * from './gens/react';
16
15
  export * from './gens/toml';
16
+ export * from './gens/vitest';
17
17
  export * from './gens/eslint';
package/dist/utils.d.cts CHANGED
@@ -1,22 +1,3 @@
1
- import type { Awaitable, InteropModuleDefault } from './types';
2
- /**
3
- * convert to array
4
- * @param {T[]} value a value
5
- * @returns {T[]} convrted array
6
- */
7
- export declare function toArray<T>(value: T | T[]): T[];
8
- /**
9
- * pascalize string
10
- * @param {string} value a string value
11
- * @returns {string} pascalized string
12
- */
13
- export declare function pascalize(value: string): string;
14
- /**
15
- * resolve module with interop default
16
- * @param {Awaitable<T>} mod a module
17
- * @returns {Promise<InteropModuleDefault<T>>} resolved module
18
- */
19
- export declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
20
1
  /**
21
2
  * load eslint plugin
22
3
  * @param {string} name plugin name
package/dist/utils.d.ts CHANGED
@@ -1,22 +1,3 @@
1
- import type { Awaitable, InteropModuleDefault } from './types';
2
- /**
3
- * convert to array
4
- * @param {T[]} value a value
5
- * @returns {T[]} convrted array
6
- */
7
- export declare function toArray<T>(value: T | T[]): T[];
8
- /**
9
- * pascalize string
10
- * @param {string} value a string value
11
- * @returns {string} pascalized string
12
- */
13
- export declare function pascalize(value: string): string;
14
- /**
15
- * resolve module with interop default
16
- * @param {Awaitable<T>} mod a module
17
- * @returns {Promise<InteropModuleDefault<T>>} resolved module
18
- */
19
- export declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
20
1
  /**
21
2
  * load eslint plugin
22
3
  * @param {string} name plugin name
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
3
  "description": "ESLint config for @kazupon",
4
- "version": "0.14.0",
4
+ "version": "0.15.0",
5
5
  "author": {
6
6
  "email": "kawakazu80@gmail.com",
7
7
  "name": "kazuya kawaguchi"
@@ -42,10 +42,12 @@
42
42
  "dependencies": {
43
43
  "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
44
44
  "@eslint/js": "^9.0.0",
45
+ "@kazupon/jts-utils": "^0.2.0",
45
46
  "eslint-flat-config-utils": "^0.3.0",
46
47
  "globals": "^15.8.0"
47
48
  },
48
49
  "peerDependencies": {
50
+ "@vitest/eslint-plugin": ">=1.0.0",
49
51
  "eslint": ">=8.56.0 || >=9.0.0",
50
52
  "eslint-config-prettier": ">=9.1.0",
51
53
  "eslint-plugin-jsdoc": ">=48.5.0",
@@ -64,6 +66,9 @@
64
66
  "typescript-eslint": ">=7.0.0"
65
67
  },
66
68
  "peerDependenciesMeta": {
69
+ "@vitest/eslint-plugin": {
70
+ "optional": true
71
+ },
67
72
  "eslint-config-prettier": {
68
73
  "optional": true
69
74
  },
@@ -114,6 +119,7 @@
114
119
  "@kazupon/prettier-config": "^0.1.1",
115
120
  "@types/eslint": "^9.6.0",
116
121
  "@types/node": "^22.5.0",
122
+ "@vitest/eslint-plugin": "^1.0.3",
117
123
  "bumpp": "^9.4.1",
118
124
  "eslint": "^9.9.0",
119
125
  "eslint-config-prettier": "^9.1.0",
@@ -167,7 +173,7 @@
167
173
  "lint:eslint": "eslint --flag unstable_ts_config .",
168
174
  "lint:prettier": "prettier . --check",
169
175
  "release": "bumpp --commit \"release: v%s\" --all --push --tag",
170
- "test": "vitest",
176
+ "test": "vitest --typecheck",
171
177
  "typecheck": "tsc -p .",
172
178
  "typegen": "pnpx jiti scripts/typegen.ts"
173
179
  }
@@ -1,4 +0,0 @@
1
- export type Awaitable<T> = T | Promise<T>;
2
- export type InteropModuleDefault<T> = T extends {
3
- default: infer U;
4
- } ? U : T;
@@ -1,4 +0,0 @@
1
- export type Awaitable<T> = T | Promise<T>;
2
- export type InteropModuleDefault<T> = T extends {
3
- default: infer U;
4
- } ? U : T;