Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 6b485d9

Browse files
azat-ioShinigami92
andauthored
Add support for vitest (#191)
Co-authored-by: Shinigami92 <[email protected]>
1 parent c848987 commit 6b485d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1433
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"eslint-plugin-sonarjs": "~0.19.0",
7979
"eslint-plugin-spellcheck": "~0.0.20",
8080
"eslint-plugin-unicorn": "~46.0.0",
81+
"eslint-plugin-vitest": "~0.1.4",
8182
"eslint-plugin-vue": "~9.11.0",
8283
"eslint-plugin-vue-pug": "~0.6.0",
8384
"expect-type": "~0.15.0",

pnpm-lock.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/src/rules/vitest/valid-title.d.ts b/src/rules/vitest/valid-title.d.ts
2+
index 8bdfe9a..83c707b 100644
3+
--- a/src/rules/vitest/valid-title.d.ts
4+
+++ b/src/rules/vitest/valid-title.d.ts
5+
@@ -8,13 +8,7 @@ export interface ValidTitleOption {
6+
disallowedWords?: string[];
7+
/**
8+
*/
9+
- [k: string]:
10+
- | string
11+
- | [string]
12+
- | [string, string]
13+
- | {
14+
- [k: string]: string | [string] | [string, string];
15+
- };
16+
+ [k: string]: any;
17+
}
18+
19+
/**

scripts/generate-rule-files/src/plugins-map.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
6868
name: 'Unicorn',
6969
module: 'eslint-plugin-unicorn',
7070
},
71+
vitest: {
72+
name: 'Vitest',
73+
module: 'eslint-plugin-vitest',
74+
},
7175
vue: {
7276
name: 'Vue',
7377
module: 'eslint-plugin-vue',
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Eslint Vitest extensions.
3+
*
4+
* @see [Eslint Vitest extensions](https://eslint.vuejs.org/user-guide/#usage)
5+
*/
6+
export type VitestExtensions =
7+
| 'plugin:vitest/all'
8+
| 'plugin:vitest/recommended';

src/config/extends/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { PrettierExtensions } from './eslint-plugin-prettier';
1212
import type { PromiseExtensions } from './eslint-plugin-promise';
1313
import type { SonarjsExtensions } from './eslint-plugin-sonarjs';
1414
import type { UnicornExtensions } from './eslint-plugin-unicorn';
15+
import type { VitestExtensions } from './eslint-plugin-vitest';
1516
import type { VueExtensions } from './eslint-plugin-vue';
1617
import type { VuePugExtensions } from './eslint-plugin-vue-pug';
1718
import type { IntlifyVueI18nExtensions } from './intlify-vue-i18n';
@@ -36,6 +37,7 @@ export type KnownExtensions = LiteralUnion<
3637
| SonarjsExtensions
3738
| TypescriptEslintExtensions
3839
| UnicornExtensions
40+
| VitestExtensions
3941
| VueExtensions
4042
| VuePugExtensions
4143
>;

src/config/plugin.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export type Plugin = LiteralUnion<
1414
| 'sonarjs'
1515
| 'spellcheck'
1616
| 'unicorn'
17+
| 'vitest'
1718
| 'vue'
1819
>;

src/rules/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { SonarJSRules } from './sonarjs';
1313
import type { SpellcheckRules } from './spellcheck';
1414
import type { TypeScriptRules } from './typescript-eslint';
1515
import type { UnicornRules } from './unicorn';
16+
import type { VitestRules } from './vitest';
1617
import type { VueRules } from './vue';
1718
import type { VueI18nRules } from './vue-i18n';
1819
import type { VuePugRules } from './vue-pug';
@@ -37,6 +38,7 @@ export type Rules = Partial<
3738
SpellcheckRules &
3839
TypeScriptRules &
3940
UnicornRules &
41+
VitestRules &
4042
VueRules &
4143
VueI18nRules &
4244
VuePugRules &
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface ConsistentTestFilenameOption {
7+
pattern?: string;
8+
allTestPattern?: string;
9+
}
10+
11+
/**
12+
* Options.
13+
*/
14+
export type ConsistentTestFilenameOptions = [ConsistentTestFilenameOption?];
15+
16+
/**
17+
* Forbidden .spec test file pattern.
18+
*
19+
* @see [consistent-test-filename](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md)
20+
*/
21+
export type ConsistentTestFilenameRuleConfig =
22+
RuleConfig<ConsistentTestFilenameOptions>;
23+
24+
/**
25+
* Forbidden .spec test file pattern.
26+
*
27+
* @see [consistent-test-filename](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md)
28+
*/
29+
export interface ConsistentTestFilenameRule {
30+
/**
31+
* Forbidden .spec test file pattern.
32+
*
33+
* @see [consistent-test-filename](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md)
34+
*/
35+
'vitest/consistent-test-filename': ConsistentTestFilenameRuleConfig;
36+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface ConsistentTestItOption {
7+
fn?: 'test' | 'it';
8+
withinDescribe?: 'test' | 'it';
9+
}
10+
11+
/**
12+
* Options.
13+
*/
14+
export type ConsistentTestItOptions = [ConsistentTestItOption?];
15+
16+
/**
17+
* Prefer test or it but not both.
18+
*
19+
* @see [consistent-test-it](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md)
20+
*/
21+
export type ConsistentTestItRuleConfig = RuleConfig<ConsistentTestItOptions>;
22+
23+
/**
24+
* Prefer test or it but not both.
25+
*
26+
* @see [consistent-test-it](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md)
27+
*/
28+
export interface ConsistentTestItRule {
29+
/**
30+
* Prefer test or it but not both.
31+
*
32+
* @see [consistent-test-it](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md)
33+
*/
34+
'vitest/consistent-test-it': ConsistentTestItRuleConfig;
35+
}

0 commit comments

Comments
 (0)