@kazupon/eslint-config 0.14.1 → 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 +2 -0
- package/dist/configs/index.d.cts +1 -0
- package/dist/configs/index.d.ts +1 -0
- package/dist/configs/vitest.d.cts +22 -0
- package/dist/configs/vitest.d.ts +22 -0
- package/dist/globs.d.cts +2 -0
- package/dist/globs.d.ts +2 -0
- package/dist/index.cjs +41 -1
- package/dist/index.js +36 -2
- package/dist/types/gens/eslint.d.cts +2 -1
- package/dist/types/gens/eslint.d.ts +2 -1
- package/dist/types/gens/vitest.d.cts +377 -0
- package/dist/types/gens/vitest.d.ts +377 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +8 -3
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/configs/index.d.cts
CHANGED
package/dist/configs/index.d.ts
CHANGED
|
@@ -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,9 +44,12 @@ 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 node_modules/.pnpm/@kazupon+jts-utils@0.
|
|
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;
|
|
@@ -427,6 +430,37 @@ async function svelte(options = {}) {
|
|
|
427
430
|
return [...svelte$1.configs["flat/recommended"], customConfig];
|
|
428
431
|
}
|
|
429
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
|
+
|
|
430
464
|
//#endregion
|
|
431
465
|
Object.defineProperty(exports, 'comments', {
|
|
432
466
|
enumerable: true,
|
|
@@ -506,6 +540,12 @@ Object.defineProperty(exports, 'unicorn', {
|
|
|
506
540
|
return unicorn;
|
|
507
541
|
}
|
|
508
542
|
});
|
|
543
|
+
Object.defineProperty(exports, 'vitest', {
|
|
544
|
+
enumerable: true,
|
|
545
|
+
get: function () {
|
|
546
|
+
return vitest;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
509
549
|
Object.defineProperty(exports, 'vue', {
|
|
510
550
|
enumerable: true,
|
|
511
551
|
get: function () {
|
package/dist/index.js
CHANGED
|
@@ -20,9 +20,12 @@ 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 node_modules/.pnpm/@kazupon+jts-utils@0.
|
|
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;
|
|
@@ -404,4 +407,35 @@ async function svelte(options = {}) {
|
|
|
404
407
|
}
|
|
405
408
|
|
|
406
409
|
//#endregion
|
|
407
|
-
|
|
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 {};
|
package/dist/types/index.d.cts
CHANGED
package/dist/types/index.d.ts
CHANGED
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.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "kawakazu80@gmail.com",
|
|
7
7
|
"name": "kazuya kawaguchi"
|
|
@@ -42,11 +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.
|
|
45
|
+
"@kazupon/jts-utils": "^0.2.0",
|
|
46
46
|
"eslint-flat-config-utils": "^0.3.0",
|
|
47
47
|
"globals": "^15.8.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
+
"@vitest/eslint-plugin": ">=1.0.0",
|
|
50
51
|
"eslint": ">=8.56.0 || >=9.0.0",
|
|
51
52
|
"eslint-config-prettier": ">=9.1.0",
|
|
52
53
|
"eslint-plugin-jsdoc": ">=48.5.0",
|
|
@@ -65,6 +66,9 @@
|
|
|
65
66
|
"typescript-eslint": ">=7.0.0"
|
|
66
67
|
},
|
|
67
68
|
"peerDependenciesMeta": {
|
|
69
|
+
"@vitest/eslint-plugin": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
68
72
|
"eslint-config-prettier": {
|
|
69
73
|
"optional": true
|
|
70
74
|
},
|
|
@@ -115,6 +119,7 @@
|
|
|
115
119
|
"@kazupon/prettier-config": "^0.1.1",
|
|
116
120
|
"@types/eslint": "^9.6.0",
|
|
117
121
|
"@types/node": "^22.5.0",
|
|
122
|
+
"@vitest/eslint-plugin": "^1.0.3",
|
|
118
123
|
"bumpp": "^9.4.1",
|
|
119
124
|
"eslint": "^9.9.0",
|
|
120
125
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -168,7 +173,7 @@
|
|
|
168
173
|
"lint:eslint": "eslint --flag unstable_ts_config .",
|
|
169
174
|
"lint:prettier": "prettier . --check",
|
|
170
175
|
"release": "bumpp --commit \"release: v%s\" --all --push --tag",
|
|
171
|
-
"test": "vitest",
|
|
176
|
+
"test": "vitest --typecheck",
|
|
172
177
|
"typecheck": "tsc -p .",
|
|
173
178
|
"typegen": "pnpx jiti scripts/typegen.ts"
|
|
174
179
|
}
|