diff --git a/package.json b/package.json index 517e2183..ee879df3 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "eslint-plugin-sonarjs": "~0.19.0", "eslint-plugin-spellcheck": "~0.0.20", "eslint-plugin-unicorn": "~46.0.0", + "eslint-plugin-vitest": "~0.1.4", "eslint-plugin-vue": "~9.11.0", "eslint-plugin-vue-pug": "~0.6.0", "expect-type": "~0.15.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4cc33e2e..0d8e20ca 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,6 +82,9 @@ devDependencies: eslint-plugin-unicorn: specifier: ~46.0.0 version: 46.0.0(eslint@8.38.0) + eslint-plugin-vitest: + specifier: ~0.1.4 + version: 0.1.4(eslint@8.38.0)(typescript@5.0.4) eslint-plugin-vue: specifier: ~9.11.0 version: 9.11.0(eslint@8.38.0) @@ -2431,6 +2434,19 @@ packages: strip-indent: 3.0.0 dev: true + /eslint-plugin-vitest@0.1.4(eslint@8.38.0)(typescript@5.0.4): + resolution: {integrity: sha512-R3/0Ch8KcQCZqKFfCxw+cQvUPdoQ6YF7yXV5/NZ9trQqoFDTUzu0vBYPSTJ7T8FLKi3nccR6ZsUvIBD2G0MXYg==} + engines: {node: 14.x || >= 16} + peerDependencies: + eslint: '>=8.0.0' + dependencies: + '@typescript-eslint/utils': 5.58.0(eslint@8.38.0)(typescript@5.0.4) + eslint: 8.38.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /eslint-plugin-vue-pug@0.6.0(eslint-plugin-vue@9.11.0)(vue-eslint-parser@9.1.1): resolution: {integrity: sha512-VFCdVctcEob2/sEWBeAVhWPXACUfLpqWpnhTK7tHXuDF+0GM2N3BeiCG0cneFvleI59B/NouGX80GXB6NGrgvA==} peerDependencies: diff --git a/scripts/generate-rule-files/diffs/rules/vitest/valid-title.d.ts.diff b/scripts/generate-rule-files/diffs/rules/vitest/valid-title.d.ts.diff new file mode 100644 index 00000000..d3a344e8 --- /dev/null +++ b/scripts/generate-rule-files/diffs/rules/vitest/valid-title.d.ts.diff @@ -0,0 +1,19 @@ +diff --git a/src/rules/vitest/valid-title.d.ts b/src/rules/vitest/valid-title.d.ts +index 8bdfe9a..83c707b 100644 +--- a/src/rules/vitest/valid-title.d.ts ++++ b/src/rules/vitest/valid-title.d.ts +@@ -8,13 +8,7 @@ export interface ValidTitleOption { + disallowedWords?: string[]; + /** + */ +- [k: string]: +- | string +- | [string] +- | [string, string] +- | { +- [k: string]: string | [string] | [string, string]; +- }; ++ [k: string]: any; + } + + /** diff --git a/scripts/generate-rule-files/src/plugins-map.ts b/scripts/generate-rule-files/src/plugins-map.ts index b4970cd8..414970eb 100644 --- a/scripts/generate-rule-files/src/plugins-map.ts +++ b/scripts/generate-rule-files/src/plugins-map.ts @@ -68,6 +68,10 @@ export const PLUGIN_REGISTRY: Readonly> = { name: 'Unicorn', module: 'eslint-plugin-unicorn', }, + vitest: { + name: 'Vitest', + module: 'eslint-plugin-vitest', + }, vue: { name: 'Vue', module: 'eslint-plugin-vue', diff --git a/src/config/extends/eslint-plugin-vitest.d.ts b/src/config/extends/eslint-plugin-vitest.d.ts new file mode 100644 index 00000000..0d4f963b --- /dev/null +++ b/src/config/extends/eslint-plugin-vitest.d.ts @@ -0,0 +1,8 @@ +/** + * Eslint Vitest extensions. + * + * @see [Eslint Vitest extensions](https://eslint.vuejs.org/user-guide/#usage) + */ +export type VitestExtensions = + | 'plugin:vitest/all' + | 'plugin:vitest/recommended'; diff --git a/src/config/extends/index.d.ts b/src/config/extends/index.d.ts index 2c1492f5..b6d405c4 100644 --- a/src/config/extends/index.d.ts +++ b/src/config/extends/index.d.ts @@ -12,6 +12,7 @@ import type { PrettierExtensions } from './eslint-plugin-prettier'; import type { PromiseExtensions } from './eslint-plugin-promise'; import type { SonarjsExtensions } from './eslint-plugin-sonarjs'; import type { UnicornExtensions } from './eslint-plugin-unicorn'; +import type { VitestExtensions } from './eslint-plugin-vitest'; import type { VueExtensions } from './eslint-plugin-vue'; import type { VuePugExtensions } from './eslint-plugin-vue-pug'; import type { IntlifyVueI18nExtensions } from './intlify-vue-i18n'; @@ -36,6 +37,7 @@ export type KnownExtensions = LiteralUnion< | SonarjsExtensions | TypescriptEslintExtensions | UnicornExtensions + | VitestExtensions | VueExtensions | VuePugExtensions >; diff --git a/src/config/plugin.d.ts b/src/config/plugin.d.ts index d951136b..b89f074d 100644 --- a/src/config/plugin.d.ts +++ b/src/config/plugin.d.ts @@ -14,5 +14,6 @@ export type Plugin = LiteralUnion< | 'sonarjs' | 'spellcheck' | 'unicorn' + | 'vitest' | 'vue' >; diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index c5e052df..a187b525 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -13,6 +13,7 @@ import type { SonarJSRules } from './sonarjs'; import type { SpellcheckRules } from './spellcheck'; import type { TypeScriptRules } from './typescript-eslint'; import type { UnicornRules } from './unicorn'; +import type { VitestRules } from './vitest'; import type { VueRules } from './vue'; import type { VueI18nRules } from './vue-i18n'; import type { VuePugRules } from './vue-pug'; @@ -37,6 +38,7 @@ export type Rules = Partial< SpellcheckRules & TypeScriptRules & UnicornRules & + VitestRules & VueRules & VueI18nRules & VuePugRules & diff --git a/src/rules/vitest/consistent-test-filename.d.ts b/src/rules/vitest/consistent-test-filename.d.ts new file mode 100644 index 00000000..264778b6 --- /dev/null +++ b/src/rules/vitest/consistent-test-filename.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ConsistentTestFilenameOption { + pattern?: string; + allTestPattern?: string; +} + +/** + * Options. + */ +export type ConsistentTestFilenameOptions = [ConsistentTestFilenameOption?]; + +/** + * Forbidden .spec test file pattern. + * + * @see [consistent-test-filename](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md) + */ +export type ConsistentTestFilenameRuleConfig = + RuleConfig; + +/** + * Forbidden .spec test file pattern. + * + * @see [consistent-test-filename](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md) + */ +export interface ConsistentTestFilenameRule { + /** + * Forbidden .spec test file pattern. + * + * @see [consistent-test-filename](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md) + */ + 'vitest/consistent-test-filename': ConsistentTestFilenameRuleConfig; +} diff --git a/src/rules/vitest/consistent-test-it.d.ts b/src/rules/vitest/consistent-test-it.d.ts new file mode 100644 index 00000000..953f0c04 --- /dev/null +++ b/src/rules/vitest/consistent-test-it.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ConsistentTestItOption { + fn?: 'test' | 'it'; + withinDescribe?: 'test' | 'it'; +} + +/** + * Options. + */ +export type ConsistentTestItOptions = [ConsistentTestItOption?]; + +/** + * Prefer test or it but not both. + * + * @see [consistent-test-it](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md) + */ +export type ConsistentTestItRuleConfig = RuleConfig; + +/** + * Prefer test or it but not both. + * + * @see [consistent-test-it](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md) + */ +export interface ConsistentTestItRule { + /** + * Prefer test or it but not both. + * + * @see [consistent-test-it](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md) + */ + 'vitest/consistent-test-it': ConsistentTestItRuleConfig; +} diff --git a/src/rules/vitest/expect-expect.d.ts b/src/rules/vitest/expect-expect.d.ts new file mode 100644 index 00000000..8fe62767 --- /dev/null +++ b/src/rules/vitest/expect-expect.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce having expectation in test body. + * + * @see [expect-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md) + */ +export type ExpectExpectRuleConfig = RuleConfig<[]>; + +/** + * Enforce having expectation in test body. + * + * @see [expect-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md) + */ +export interface ExpectExpectRule { + /** + * Enforce having expectation in test body. + * + * @see [expect-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md) + */ + 'vitest/expect-expect': ExpectExpectRuleConfig; +} diff --git a/src/rules/vitest/index.d.ts b/src/rules/vitest/index.d.ts new file mode 100644 index 00000000..bb5e4ec1 --- /dev/null +++ b/src/rules/vitest/index.d.ts @@ -0,0 +1,102 @@ +import type { ConsistentTestFilenameRule } from './consistent-test-filename'; +import type { ConsistentTestItRule } from './consistent-test-it'; +import type { ExpectExpectRule } from './expect-expect'; +import type { MaxExpectsRule } from './max-expects'; +import type { MaxNestedDescribeRule } from './max-nested-describe'; +import type { NoAliasMethodsRule } from './no-alias-methods'; +import type { NoCommentedOutTestsRule } from './no-commented-out-tests'; +import type { NoConditionalExpectRule } from './no-conditional-expect'; +import type { NoConditionalInTestRule } from './no-conditional-in-test'; +import type { NoConditionalTestsRule } from './no-conditional-tests'; +import type { NoDisabledTestsRule } from './no-disabled-tests'; +import type { NoDoneCallbackRule } from './no-done-callback'; +import type { NoDuplicateHooksRule } from './no-duplicate-hooks'; +import type { NoFocusedTestsRule } from './no-focused-tests'; +import type { NoHooksRule } from './no-hooks'; +import type { NoIdenticalTitleRule } from './no-identical-title'; +import type { NoInterpolationInSnapshotsRule } from './no-interpolation-in-snapshots'; +import type { NoLargeSnapshotsRule } from './no-large-snapshots'; +import type { NoMocksImportRule } from './no-mocks-import'; +import type { NoRestrictedMatchersRule } from './no-restricted-matchers'; +import type { NoRestrictedViMethodsRule } from './no-restricted-vi-methods'; +import type { NoStandaloneExpectRule } from './no-standalone-expect'; +import type { NoTestPrefixesRule } from './no-test-prefixes'; +import type { NoTestReturnStatementRule } from './no-test-return-statement'; +import type { PreferCalledWithRule } from './prefer-called-with'; +import type { PreferComparisonMatcherRule } from './prefer-comparison-matcher'; +import type { PreferEachRule } from './prefer-each'; +import type { PreferEqualityMatcherRule } from './prefer-equality-matcher'; +import type { PreferExpectResolvesRule } from './prefer-expect-resolves'; +import type { PreferHooksInOrderRule } from './prefer-hooks-in-order'; +import type { PreferHooksOnTopRule } from './prefer-hooks-on-top'; +import type { PreferLowercaseTitleRule } from './prefer-lowercase-title'; +import type { PreferSnapshotHintRule } from './prefer-snapshot-hint'; +import type { PreferSpyOnRule } from './prefer-spy-on'; +import type { PreferStrictEqualRule } from './prefer-strict-equal'; +import type { PreferToBeRule } from './prefer-to-be'; +import type { PreferToBeFalsyRule } from './prefer-to-be-falsy'; +import type { PreferToBeObjectRule } from './prefer-to-be-object'; +import type { PreferToBeTruthyRule } from './prefer-to-be-truthy'; +import type { PreferToContainRule } from './prefer-to-contain'; +import type { PreferToHaveLengthRule } from './prefer-to-have-length'; +import type { PreferTodoRule } from './prefer-todo'; +import type { PreferMockPromiseShorthandRule } from './preferMockPromiseShorthand'; +import type { RequireHookRule } from './require-hook'; +import type { RequireToThrowMessageRule } from './require-to-throw-message'; +import type { RequireTopLevelDescribeRule } from './require-top-level-describe'; +import type { ValidDescribeCallbackRule } from './valid-describe-callback'; +import type { ValidExpectRule } from './valid-expect'; +import type { ValidTitleRule } from './valid-title'; + +/** + * All Vitest rules. + */ +export type VitestRules = PreferLowercaseTitleRule & + MaxNestedDescribeRule & + NoIdenticalTitleRule & + NoFocusedTestsRule & + NoConditionalTestsRule & + ExpectExpectRule & + ConsistentTestItRule & + PreferToBeRule & + NoHooksRule & + NoRestrictedViMethodsRule & + ConsistentTestFilenameRule & + MaxExpectsRule & + NoAliasMethodsRule & + NoCommentedOutTestsRule & + NoConditionalExpectRule & + NoConditionalInTestRule & + NoDisabledTestsRule & + NoDoneCallbackRule & + NoDuplicateHooksRule & + NoLargeSnapshotsRule & + NoInterpolationInSnapshotsRule & + NoMocksImportRule & + NoRestrictedMatchersRule & + NoStandaloneExpectRule & + NoTestPrefixesRule & + NoTestReturnStatementRule & + PreferCalledWithRule & + ValidTitleRule & + ValidExpectRule & + PreferToBeFalsyRule & + PreferToBeObjectRule & + PreferToBeTruthyRule & + PreferToHaveLengthRule & + PreferEqualityMatcherRule & + PreferStrictEqualRule & + PreferExpectResolvesRule & + PreferEachRule & + PreferHooksOnTopRule & + PreferHooksInOrderRule & + PreferMockPromiseShorthandRule & + PreferSnapshotHintRule & + ValidDescribeCallbackRule & + RequireTopLevelDescribeRule & + RequireToThrowMessageRule & + RequireHookRule & + PreferTodoRule & + PreferSpyOnRule & + PreferComparisonMatcherRule & + PreferToContainRule; diff --git a/src/rules/vitest/max-expects.d.ts b/src/rules/vitest/max-expects.d.ts new file mode 100644 index 00000000..03f0ca77 --- /dev/null +++ b/src/rules/vitest/max-expects.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface MaxExpectsOption { + max?: number; +} + +/** + * Options. + */ +export type MaxExpectsOptions = [MaxExpectsOption?]; + +/** + * Enforce a maximum number of expect per test. + * + * @see [max-expects](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md) + */ +export type MaxExpectsRuleConfig = RuleConfig; + +/** + * Enforce a maximum number of expect per test. + * + * @see [max-expects](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md) + */ +export interface MaxExpectsRule { + /** + * Enforce a maximum number of expect per test. + * + * @see [max-expects](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md) + */ + 'vitest/max-expects': MaxExpectsRuleConfig; +} diff --git a/src/rules/vitest/max-nested-describe.d.ts b/src/rules/vitest/max-nested-describe.d.ts new file mode 100644 index 00000000..500a20c9 --- /dev/null +++ b/src/rules/vitest/max-nested-describe.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface MaxNestedDescribeOption { + max?: number; +} + +/** + * Options. + */ +export type MaxNestedDescribeOptions = [MaxNestedDescribeOption?]; + +/** + * Nested describe block should be less than set max value or default value. + * + * @see [max-nested-describe](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md) + */ +export type MaxNestedDescribeRuleConfig = RuleConfig; + +/** + * Nested describe block should be less than set max value or default value. + * + * @see [max-nested-describe](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md) + */ +export interface MaxNestedDescribeRule { + /** + * Nested describe block should be less than set max value or default value. + * + * @see [max-nested-describe](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md) + */ + 'vitest/max-nested-describe': MaxNestedDescribeRuleConfig; +} diff --git a/src/rules/vitest/no-alias-methods.d.ts b/src/rules/vitest/no-alias-methods.d.ts new file mode 100644 index 00000000..6759a021 --- /dev/null +++ b/src/rules/vitest/no-alias-methods.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow alias methods. + * + * @see [no-alias-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md) + */ +export type NoAliasMethodsRuleConfig = RuleConfig<[]>; + +/** + * Disallow alias methods. + * + * @see [no-alias-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md) + */ +export interface NoAliasMethodsRule { + /** + * Disallow alias methods. + * + * @see [no-alias-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md) + */ + 'vitest/no-alias-methods': NoAliasMethodsRuleConfig; +} diff --git a/src/rules/vitest/no-commented-out-tests.d.ts b/src/rules/vitest/no-commented-out-tests.d.ts new file mode 100644 index 00000000..55073dd4 --- /dev/null +++ b/src/rules/vitest/no-commented-out-tests.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow commented out tests. + * + * @see [no-commented-out-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md) + */ +export type NoCommentedOutTestsRuleConfig = RuleConfig<[]>; + +/** + * Disallow commented out tests. + * + * @see [no-commented-out-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md) + */ +export interface NoCommentedOutTestsRule { + /** + * Disallow commented out tests. + * + * @see [no-commented-out-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md) + */ + 'vitest/no-commented-out-tests': NoCommentedOutTestsRuleConfig; +} diff --git a/src/rules/vitest/no-conditional-expect.d.ts b/src/rules/vitest/no-conditional-expect.d.ts new file mode 100644 index 00000000..161f942b --- /dev/null +++ b/src/rules/vitest/no-conditional-expect.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow conditional expects. + * + * @see [no-conditional-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md) + */ +export type NoConditionalExpectRuleConfig = RuleConfig<[]>; + +/** + * Disallow conditional expects. + * + * @see [no-conditional-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md) + */ +export interface NoConditionalExpectRule { + /** + * Disallow conditional expects. + * + * @see [no-conditional-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md) + */ + 'vitest/no-conditional-expect': NoConditionalExpectRuleConfig; +} diff --git a/src/rules/vitest/no-conditional-in-test.d.ts b/src/rules/vitest/no-conditional-in-test.d.ts new file mode 100644 index 00000000..62373eb8 --- /dev/null +++ b/src/rules/vitest/no-conditional-in-test.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow conditional tests. + * + * @see [no-conditional-in-test](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md) + */ +export type NoConditionalInTestRuleConfig = RuleConfig<[]>; + +/** + * Disallow conditional tests. + * + * @see [no-conditional-in-test](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md) + */ +export interface NoConditionalInTestRule { + /** + * Disallow conditional tests. + * + * @see [no-conditional-in-test](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md) + */ + 'vitest/no-conditional-in-test': NoConditionalInTestRuleConfig; +} diff --git a/src/rules/vitest/no-conditional-tests.d.ts b/src/rules/vitest/no-conditional-tests.d.ts new file mode 100644 index 00000000..cf24486b --- /dev/null +++ b/src/rules/vitest/no-conditional-tests.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow conditional tests. + * + * @see [no-conditional-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md) + */ +export type NoConditionalTestsRuleConfig = RuleConfig<[]>; + +/** + * Disallow conditional tests. + * + * @see [no-conditional-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md) + */ +export interface NoConditionalTestsRule { + /** + * Disallow conditional tests. + * + * @see [no-conditional-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md) + */ + 'vitest/no-conditional-tests': NoConditionalTestsRuleConfig; +} diff --git a/src/rules/vitest/no-disabled-tests.d.ts b/src/rules/vitest/no-disabled-tests.d.ts new file mode 100644 index 00000000..24a67632 --- /dev/null +++ b/src/rules/vitest/no-disabled-tests.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow disabled tests. + * + * @see [no-disabled-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md) + */ +export type NoDisabledTestsRuleConfig = RuleConfig<[]>; + +/** + * Disallow disabled tests. + * + * @see [no-disabled-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md) + */ +export interface NoDisabledTestsRule { + /** + * Disallow disabled tests. + * + * @see [no-disabled-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md) + */ + 'vitest/no-disabled-tests': NoDisabledTestsRuleConfig; +} diff --git a/src/rules/vitest/no-done-callback.d.ts b/src/rules/vitest/no-done-callback.d.ts new file mode 100644 index 00000000..23b2343c --- /dev/null +++ b/src/rules/vitest/no-done-callback.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow using a callback in asynchrounous tests and hooks. + * + * @see [no-done-callback](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md) + */ +export type NoDoneCallbackRuleConfig = RuleConfig<[]>; + +/** + * Disallow using a callback in asynchrounous tests and hooks. + * + * @see [no-done-callback](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md) + */ +export interface NoDoneCallbackRule { + /** + * Disallow using a callback in asynchrounous tests and hooks. + * + * @see [no-done-callback](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md) + */ + 'vitest/no-done-callback': NoDoneCallbackRuleConfig; +} diff --git a/src/rules/vitest/no-duplicate-hooks.d.ts b/src/rules/vitest/no-duplicate-hooks.d.ts new file mode 100644 index 00000000..68f67e44 --- /dev/null +++ b/src/rules/vitest/no-duplicate-hooks.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow duplicate hooks and teardown hooks. + * + * @see [no-duplicate-hooks](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md) + */ +export type NoDuplicateHooksRuleConfig = RuleConfig<[]>; + +/** + * Disallow duplicate hooks and teardown hooks. + * + * @see [no-duplicate-hooks](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md) + */ +export interface NoDuplicateHooksRule { + /** + * Disallow duplicate hooks and teardown hooks. + * + * @see [no-duplicate-hooks](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md) + */ + 'vitest/no-duplicate-hooks': NoDuplicateHooksRuleConfig; +} diff --git a/src/rules/vitest/no-focused-tests.d.ts b/src/rules/vitest/no-focused-tests.d.ts new file mode 100644 index 00000000..98d2e17c --- /dev/null +++ b/src/rules/vitest/no-focused-tests.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow focused tests. + * + * @see [no-focused-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md) + */ +export type NoFocusedTestsRuleConfig = RuleConfig<[]>; + +/** + * Disallow focused tests. + * + * @see [no-focused-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md) + */ +export interface NoFocusedTestsRule { + /** + * Disallow focused tests. + * + * @see [no-focused-tests](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md) + */ + 'vitest/no-focused-tests': NoFocusedTestsRuleConfig; +} diff --git a/src/rules/vitest/no-hooks.d.ts b/src/rules/vitest/no-hooks.d.ts new file mode 100644 index 00000000..353821b0 --- /dev/null +++ b/src/rules/vitest/no-hooks.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoHooksOption { + allow?: any[]; +} + +/** + * Options. + */ +export type NoHooksOptions = [NoHooksOption?]; + +/** + * Disallow setup and teardown hooks. + * + * @see [no-hooks](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md) + */ +export type NoHooksRuleConfig = RuleConfig; + +/** + * Disallow setup and teardown hooks. + * + * @see [no-hooks](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md) + */ +export interface NoHooksRule { + /** + * Disallow setup and teardown hooks. + * + * @see [no-hooks](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md) + */ + 'vitest/no-hooks': NoHooksRuleConfig; +} diff --git a/src/rules/vitest/no-identical-title.d.ts b/src/rules/vitest/no-identical-title.d.ts new file mode 100644 index 00000000..d3fc16db --- /dev/null +++ b/src/rules/vitest/no-identical-title.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow identical titles. + * + * @see [no-identical-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md) + */ +export type NoIdenticalTitleRuleConfig = RuleConfig<[]>; + +/** + * Disallow identical titles. + * + * @see [no-identical-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md) + */ +export interface NoIdenticalTitleRule { + /** + * Disallow identical titles. + * + * @see [no-identical-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md) + */ + 'vitest/no-identical-title': NoIdenticalTitleRuleConfig; +} diff --git a/src/rules/vitest/no-interpolation-in-snapshots.d.ts b/src/rules/vitest/no-interpolation-in-snapshots.d.ts new file mode 100644 index 00000000..16c4dba5 --- /dev/null +++ b/src/rules/vitest/no-interpolation-in-snapshots.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow string interpolation in snapshots. + * + * @see [no-interpolation-in-snapshots](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md) + */ +export type NoInterpolationInSnapshotsRuleConfig = RuleConfig<[]>; + +/** + * Disallow string interpolation in snapshots. + * + * @see [no-interpolation-in-snapshots](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md) + */ +export interface NoInterpolationInSnapshotsRule { + /** + * Disallow string interpolation in snapshots. + * + * @see [no-interpolation-in-snapshots](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md) + */ + 'vitest/no-interpolation-in-snapshots': NoInterpolationInSnapshotsRuleConfig; +} diff --git a/src/rules/vitest/no-large-snapshots.d.ts b/src/rules/vitest/no-large-snapshots.d.ts new file mode 100644 index 00000000..e66e9c0e --- /dev/null +++ b/src/rules/vitest/no-large-snapshots.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoLargeSnapshotsOption { + maxSize?: number; + inlineMaxSize?: number; + allowedSnapshots?: { + [k: string]: any[]; + }; +} + +/** + * Options. + */ +export type NoLargeSnapshotsOptions = [NoLargeSnapshotsOption?]; + +/** + * Disallow large snapshots. + * + * @see [no-large-snapshots](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md) + */ +export type NoLargeSnapshotsRuleConfig = RuleConfig; + +/** + * Disallow large snapshots. + * + * @see [no-large-snapshots](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md) + */ +export interface NoLargeSnapshotsRule { + /** + * Disallow large snapshots. + * + * @see [no-large-snapshots](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md) + */ + 'vitest/no-large-snapshots': NoLargeSnapshotsRuleConfig; +} diff --git a/src/rules/vitest/no-mocks-import.d.ts b/src/rules/vitest/no-mocks-import.d.ts new file mode 100644 index 00000000..f3d6479a --- /dev/null +++ b/src/rules/vitest/no-mocks-import.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow importing from __mocks__ directory. + * + * @see [no-mocks-import](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md) + */ +export type NoMocksImportRuleConfig = RuleConfig<[]>; + +/** + * Disallow importing from __mocks__ directory. + * + * @see [no-mocks-import](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md) + */ +export interface NoMocksImportRule { + /** + * Disallow importing from __mocks__ directory. + * + * @see [no-mocks-import](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md) + */ + 'vitest/no-mocks-import': NoMocksImportRuleConfig; +} diff --git a/src/rules/vitest/no-restricted-matchers.d.ts b/src/rules/vitest/no-restricted-matchers.d.ts new file mode 100644 index 00000000..01f283c3 --- /dev/null +++ b/src/rules/vitest/no-restricted-matchers.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoRestrictedMatchersOption { + [k: string]: string | null; +} + +/** + * Options. + */ +export type NoRestrictedMatchersOptions = [NoRestrictedMatchersOption?]; + +/** + * Disallow the use of certain matchers. + * + * @see [no-restricted-matchers](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md) + */ +export type NoRestrictedMatchersRuleConfig = + RuleConfig; + +/** + * Disallow the use of certain matchers. + * + * @see [no-restricted-matchers](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md) + */ +export interface NoRestrictedMatchersRule { + /** + * Disallow the use of certain matchers. + * + * @see [no-restricted-matchers](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md) + */ + 'vitest/no-restricted-matchers': NoRestrictedMatchersRuleConfig; +} diff --git a/src/rules/vitest/no-restricted-vi-methods.d.ts b/src/rules/vitest/no-restricted-vi-methods.d.ts new file mode 100644 index 00000000..b8c45e0f --- /dev/null +++ b/src/rules/vitest/no-restricted-vi-methods.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoRestrictedViMethodsOption { + [k: string]: string | null; +} + +/** + * Options. + */ +export type NoRestrictedViMethodsOptions = [NoRestrictedViMethodsOption?]; + +/** + * Disallow specific `vi.` methods. + * + * @see [no-restricted-vi-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md) + */ +export type NoRestrictedViMethodsRuleConfig = + RuleConfig; + +/** + * Disallow specific `vi.` methods. + * + * @see [no-restricted-vi-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md) + */ +export interface NoRestrictedViMethodsRule { + /** + * Disallow specific `vi.` methods. + * + * @see [no-restricted-vi-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md) + */ + 'vitest/no-restricted-vi-methods': NoRestrictedViMethodsRuleConfig; +} diff --git a/src/rules/vitest/no-standalone-expect.d.ts b/src/rules/vitest/no-standalone-expect.d.ts new file mode 100644 index 00000000..23efa7c4 --- /dev/null +++ b/src/rules/vitest/no-standalone-expect.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoStandaloneExpectOption { + additionalTestBlockFunctions?: string[]; +} + +/** + * Options. + */ +export type NoStandaloneExpectOptions = [NoStandaloneExpectOption?]; + +/** + * Disallow using `expect` outside of `it` or `test` blocks. + * + * @see [no-standalone-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md) + */ +export type NoStandaloneExpectRuleConfig = + RuleConfig; + +/** + * Disallow using `expect` outside of `it` or `test` blocks. + * + * @see [no-standalone-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md) + */ +export interface NoStandaloneExpectRule { + /** + * Disallow using `expect` outside of `it` or `test` blocks. + * + * @see [no-standalone-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md) + */ + 'vitest/no-standalone-expect': NoStandaloneExpectRuleConfig; +} diff --git a/src/rules/vitest/no-test-prefixes.d.ts b/src/rules/vitest/no-test-prefixes.d.ts new file mode 100644 index 00000000..4444422d --- /dev/null +++ b/src/rules/vitest/no-test-prefixes.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow using `test` as a prefix. + * + * @see [no-test-prefixes](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md) + */ +export type NoTestPrefixesRuleConfig = RuleConfig<[]>; + +/** + * Disallow using `test` as a prefix. + * + * @see [no-test-prefixes](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md) + */ +export interface NoTestPrefixesRule { + /** + * Disallow using `test` as a prefix. + * + * @see [no-test-prefixes](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md) + */ + 'vitest/no-test-prefixes': NoTestPrefixesRuleConfig; +} diff --git a/src/rules/vitest/no-test-return-statement.d.ts b/src/rules/vitest/no-test-return-statement.d.ts new file mode 100644 index 00000000..bd67a3eb --- /dev/null +++ b/src/rules/vitest/no-test-return-statement.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow return statements in tests. + * + * @see [no-test-return-statement](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md) + */ +export type NoTestReturnStatementRuleConfig = RuleConfig<[]>; + +/** + * Disallow return statements in tests. + * + * @see [no-test-return-statement](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md) + */ +export interface NoTestReturnStatementRule { + /** + * Disallow return statements in tests. + * + * @see [no-test-return-statement](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md) + */ + 'vitest/no-test-return-statement': NoTestReturnStatementRuleConfig; +} diff --git a/src/rules/vitest/prefer-called-with.d.ts b/src/rules/vitest/prefer-called-with.d.ts new file mode 100644 index 00000000..3da92292 --- /dev/null +++ b/src/rules/vitest/prefer-called-with.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`. + * + * @see [prefer-called-with](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md) + */ +export type PreferCalledWithRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`. + * + * @see [prefer-called-with](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md) + */ +export interface PreferCalledWithRule { + /** + * Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`. + * + * @see [prefer-called-with](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md) + */ + 'vitest/prefer-called-with': PreferCalledWithRuleConfig; +} diff --git a/src/rules/vitest/prefer-comparison-matcher.d.ts b/src/rules/vitest/prefer-comparison-matcher.d.ts new file mode 100644 index 00000000..b2b2fea5 --- /dev/null +++ b/src/rules/vitest/prefer-comparison-matcher.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using the built-in comparison matchers. + * + * @see [prefer-comparison-matcher](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md) + */ +export type PreferComparisonMatcherRuleConfig = RuleConfig<[]>; + +/** + * Suggest using the built-in comparison matchers. + * + * @see [prefer-comparison-matcher](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md) + */ +export interface PreferComparisonMatcherRule { + /** + * Suggest using the built-in comparison matchers. + * + * @see [prefer-comparison-matcher](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md) + */ + 'vitest/prefer-comparison-matcher': PreferComparisonMatcherRuleConfig; +} diff --git a/src/rules/vitest/prefer-each.d.ts b/src/rules/vitest/prefer-each.d.ts new file mode 100644 index 00000000..5e90a08b --- /dev/null +++ b/src/rules/vitest/prefer-each.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `each` rather than manual loops. + * + * @see [prefer-each](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md) + */ +export type PreferEachRuleConfig = RuleConfig<[]>; + +/** + * Prefer `each` rather than manual loops. + * + * @see [prefer-each](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md) + */ +export interface PreferEachRule { + /** + * Prefer `each` rather than manual loops. + * + * @see [prefer-each](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md) + */ + 'vitest/prefer-each': PreferEachRuleConfig; +} diff --git a/src/rules/vitest/prefer-equality-matcher.d.ts b/src/rules/vitest/prefer-equality-matcher.d.ts new file mode 100644 index 00000000..69cf3a56 --- /dev/null +++ b/src/rules/vitest/prefer-equality-matcher.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using the built-in quality matchers. + * + * @see [prefer-equality-matcher](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md) + */ +export type PreferEqualityMatcherRuleConfig = RuleConfig<[]>; + +/** + * Suggest using the built-in quality matchers. + * + * @see [prefer-equality-matcher](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md) + */ +export interface PreferEqualityMatcherRule { + /** + * Suggest using the built-in quality matchers. + * + * @see [prefer-equality-matcher](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md) + */ + 'vitest/prefer-equality-matcher': PreferEqualityMatcherRuleConfig; +} diff --git a/src/rules/vitest/prefer-expect-resolves.d.ts b/src/rules/vitest/prefer-expect-resolves.d.ts new file mode 100644 index 00000000..6eca5097 --- /dev/null +++ b/src/rules/vitest/prefer-expect-resolves.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `expect().resolves` over `expect(await ...)` syntax. + * + * @see [prefer-expect-resolves](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md) + */ +export type PreferExpectResolvesRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `expect().resolves` over `expect(await ...)` syntax. + * + * @see [prefer-expect-resolves](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md) + */ +export interface PreferExpectResolvesRule { + /** + * Suggest using `expect().resolves` over `expect(await ...)` syntax. + * + * @see [prefer-expect-resolves](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md) + */ + 'vitest/prefer-expect-resolves': PreferExpectResolvesRuleConfig; +} diff --git a/src/rules/vitest/prefer-hooks-in-order.d.ts b/src/rules/vitest/prefer-hooks-in-order.d.ts new file mode 100644 index 00000000..988c7cd2 --- /dev/null +++ b/src/rules/vitest/prefer-hooks-in-order.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer having hooks in consistent order. + * + * @see [prefer-hooks-in-order](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md) + */ +export type PreferHooksInOrderRuleConfig = RuleConfig<[]>; + +/** + * Prefer having hooks in consistent order. + * + * @see [prefer-hooks-in-order](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md) + */ +export interface PreferHooksInOrderRule { + /** + * Prefer having hooks in consistent order. + * + * @see [prefer-hooks-in-order](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md) + */ + 'vitest/prefer-hooks-in-order': PreferHooksInOrderRuleConfig; +} diff --git a/src/rules/vitest/prefer-hooks-on-top.d.ts b/src/rules/vitest/prefer-hooks-on-top.d.ts new file mode 100644 index 00000000..32835e49 --- /dev/null +++ b/src/rules/vitest/prefer-hooks-on-top.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest having hooks before any test cases. + * + * @see [prefer-hooks-on-top](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md) + */ +export type PreferHooksOnTopRuleConfig = RuleConfig<[]>; + +/** + * Suggest having hooks before any test cases. + * + * @see [prefer-hooks-on-top](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md) + */ +export interface PreferHooksOnTopRule { + /** + * Suggest having hooks before any test cases. + * + * @see [prefer-hooks-on-top](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md) + */ + 'vitest/prefer-hooks-on-top': PreferHooksOnTopRuleConfig; +} diff --git a/src/rules/vitest/prefer-lowercase-title.d.ts b/src/rules/vitest/prefer-lowercase-title.d.ts new file mode 100644 index 00000000..0d04a7d2 --- /dev/null +++ b/src/rules/vitest/prefer-lowercase-title.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferLowercaseTitleOption { + ignore?: ('describe' | 'test' | 'it')[]; + allowedPrefixes?: string[]; + ignoreTopLevelDescribe?: boolean; +} + +/** + * Options. + */ +export type PreferLowercaseTitleOptions = [PreferLowercaseTitleOption?]; + +/** + * Enforce lowercase titles. + * + * @see [prefer-lowercase-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md) + */ +export type PreferLowercaseTitleRuleConfig = + RuleConfig; + +/** + * Enforce lowercase titles. + * + * @see [prefer-lowercase-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md) + */ +export interface PreferLowercaseTitleRule { + /** + * Enforce lowercase titles. + * + * @see [prefer-lowercase-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md) + */ + 'vitest/prefer-lowercase-title': PreferLowercaseTitleRuleConfig; +} diff --git a/src/rules/vitest/prefer-snapshot-hint.d.ts b/src/rules/vitest/prefer-snapshot-hint.d.ts new file mode 100644 index 00000000..28ec85fc --- /dev/null +++ b/src/rules/vitest/prefer-snapshot-hint.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type PreferSnapshotHintOption = 'always' | 'multi'; + +/** + * Options. + */ +export type PreferSnapshotHintOptions = [PreferSnapshotHintOption?]; + +/** + * Prefer including a hint with external snapshots. + * + * @see [prefer-snapshot-hint](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md) + */ +export type PreferSnapshotHintRuleConfig = + RuleConfig; + +/** + * Prefer including a hint with external snapshots. + * + * @see [prefer-snapshot-hint](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md) + */ +export interface PreferSnapshotHintRule { + /** + * Prefer including a hint with external snapshots. + * + * @see [prefer-snapshot-hint](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md) + */ + 'vitest/prefer-snapshot-hint': PreferSnapshotHintRuleConfig; +} diff --git a/src/rules/vitest/prefer-spy-on.d.ts b/src/rules/vitest/prefer-spy-on.d.ts new file mode 100644 index 00000000..f477ca83 --- /dev/null +++ b/src/rules/vitest/prefer-spy-on.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `vi.spyOn`. + * + * @see [prefer-spy-on](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md) + */ +export type PreferSpyOnRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `vi.spyOn`. + * + * @see [prefer-spy-on](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md) + */ +export interface PreferSpyOnRule { + /** + * Suggest using `vi.spyOn`. + * + * @see [prefer-spy-on](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md) + */ + 'vitest/prefer-spy-on': PreferSpyOnRuleConfig; +} diff --git a/src/rules/vitest/prefer-strict-equal.d.ts b/src/rules/vitest/prefer-strict-equal.d.ts new file mode 100644 index 00000000..3326e388 --- /dev/null +++ b/src/rules/vitest/prefer-strict-equal.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer strict equal over equal. + * + * @see [prefer-strict-equal](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md) + */ +export type PreferStrictEqualRuleConfig = RuleConfig<[]>; + +/** + * Prefer strict equal over equal. + * + * @see [prefer-strict-equal](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md) + */ +export interface PreferStrictEqualRule { + /** + * Prefer strict equal over equal. + * + * @see [prefer-strict-equal](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md) + */ + 'vitest/prefer-strict-equal': PreferStrictEqualRuleConfig; +} diff --git a/src/rules/vitest/prefer-to-be-falsy.d.ts b/src/rules/vitest/prefer-to-be-falsy.d.ts new file mode 100644 index 00000000..0bfb3589 --- /dev/null +++ b/src/rules/vitest/prefer-to-be-falsy.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using toBeFalsy(). + * + * @see [prefer-to-be-falsy](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md) + */ +export type PreferToBeFalsyRuleConfig = RuleConfig<[]>; + +/** + * Suggest using toBeFalsy(). + * + * @see [prefer-to-be-falsy](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md) + */ +export interface PreferToBeFalsyRule { + /** + * Suggest using toBeFalsy(). + * + * @see [prefer-to-be-falsy](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md) + */ + 'vitest/prefer-to-be-falsy': PreferToBeFalsyRuleConfig; +} diff --git a/src/rules/vitest/prefer-to-be-object.d.ts b/src/rules/vitest/prefer-to-be-object.d.ts new file mode 100644 index 00000000..8762cdca --- /dev/null +++ b/src/rules/vitest/prefer-to-be-object.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer toBeObject(). + * + * @see [prefer-to-be-object](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md) + */ +export type PreferToBeObjectRuleConfig = RuleConfig<[]>; + +/** + * Prefer toBeObject(). + * + * @see [prefer-to-be-object](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md) + */ +export interface PreferToBeObjectRule { + /** + * Prefer toBeObject(). + * + * @see [prefer-to-be-object](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md) + */ + 'vitest/prefer-to-be-object': PreferToBeObjectRuleConfig; +} diff --git a/src/rules/vitest/prefer-to-be-truthy.d.ts b/src/rules/vitest/prefer-to-be-truthy.d.ts new file mode 100644 index 00000000..3da107e2 --- /dev/null +++ b/src/rules/vitest/prefer-to-be-truthy.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `toBeTruthy`. + * + * @see [prefer-to-be-truthy](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md) + */ +export type PreferToBeTruthyRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `toBeTruthy`. + * + * @see [prefer-to-be-truthy](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md) + */ +export interface PreferToBeTruthyRule { + /** + * Suggest using `toBeTruthy`. + * + * @see [prefer-to-be-truthy](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md) + */ + 'vitest/prefer-to-be-truthy': PreferToBeTruthyRuleConfig; +} diff --git a/src/rules/vitest/prefer-to-be.d.ts b/src/rules/vitest/prefer-to-be.d.ts new file mode 100644 index 00000000..772c14b4 --- /dev/null +++ b/src/rules/vitest/prefer-to-be.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using toBe(). + * + * @see [prefer-to-be](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md) + */ +export type PreferToBeRuleConfig = RuleConfig<[]>; + +/** + * Suggest using toBe(). + * + * @see [prefer-to-be](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md) + */ +export interface PreferToBeRule { + /** + * Suggest using toBe(). + * + * @see [prefer-to-be](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md) + */ + 'vitest/prefer-to-be': PreferToBeRuleConfig; +} diff --git a/src/rules/vitest/prefer-to-contain.d.ts b/src/rules/vitest/prefer-to-contain.d.ts new file mode 100644 index 00000000..853b73fe --- /dev/null +++ b/src/rules/vitest/prefer-to-contain.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer using toContain(). + * + * @see [prefer-to-contain](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md) + */ +export type PreferToContainRuleConfig = RuleConfig<[]>; + +/** + * Prefer using toContain(). + * + * @see [prefer-to-contain](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md) + */ +export interface PreferToContainRule { + /** + * Prefer using toContain(). + * + * @see [prefer-to-contain](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md) + */ + 'vitest/prefer-to-contain': PreferToContainRuleConfig; +} diff --git a/src/rules/vitest/prefer-to-have-length.d.ts b/src/rules/vitest/prefer-to-have-length.d.ts new file mode 100644 index 00000000..b5a66f64 --- /dev/null +++ b/src/rules/vitest/prefer-to-have-length.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using toHaveLength(). + * + * @see [prefer-to-have-length](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md) + */ +export type PreferToHaveLengthRuleConfig = RuleConfig<[]>; + +/** + * Suggest using toHaveLength(). + * + * @see [prefer-to-have-length](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md) + */ +export interface PreferToHaveLengthRule { + /** + * Suggest using toHaveLength(). + * + * @see [prefer-to-have-length](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md) + */ + 'vitest/prefer-to-have-length': PreferToHaveLengthRuleConfig; +} diff --git a/src/rules/vitest/prefer-todo.d.ts b/src/rules/vitest/prefer-todo.d.ts new file mode 100644 index 00000000..18dc1920 --- /dev/null +++ b/src/rules/vitest/prefer-todo.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `test.todo`. + * + * @see [prefer-todo](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md) + */ +export type PreferTodoRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `test.todo`. + * + * @see [prefer-todo](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md) + */ +export interface PreferTodoRule { + /** + * Suggest using `test.todo`. + * + * @see [prefer-todo](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md) + */ + 'vitest/prefer-todo': PreferTodoRuleConfig; +} diff --git a/src/rules/vitest/preferMockPromiseShorthand.d.ts b/src/rules/vitest/preferMockPromiseShorthand.d.ts new file mode 100644 index 00000000..891a6f79 --- /dev/null +++ b/src/rules/vitest/preferMockPromiseShorthand.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer mock resolved/rejected shorthands for promises. + * + * @see [preferMockPromiseShorthand](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/preferMockPromiseShorthand.md) + */ +export type PreferMockPromiseShorthandRuleConfig = RuleConfig<[]>; + +/** + * Prefer mock resolved/rejected shorthands for promises. + * + * @see [preferMockPromiseShorthand](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/preferMockPromiseShorthand.md) + */ +export interface PreferMockPromiseShorthandRule { + /** + * Prefer mock resolved/rejected shorthands for promises. + * + * @see [preferMockPromiseShorthand](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/preferMockPromiseShorthand.md) + */ + 'vitest/preferMockPromiseShorthand': PreferMockPromiseShorthandRuleConfig; +} diff --git a/src/rules/vitest/require-hook.d.ts b/src/rules/vitest/require-hook.d.ts new file mode 100644 index 00000000..ffc55150 --- /dev/null +++ b/src/rules/vitest/require-hook.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface RequireHookOption { + allowedFunctionCalls?: string[]; +} + +/** + * Options. + */ +export type RequireHookOptions = [RequireHookOption?]; + +/** + * Require setup and teardown to be within a hook. + * + * @see [require-hook](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md) + */ +export type RequireHookRuleConfig = RuleConfig; + +/** + * Require setup and teardown to be within a hook. + * + * @see [require-hook](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md) + */ +export interface RequireHookRule { + /** + * Require setup and teardown to be within a hook. + * + * @see [require-hook](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md) + */ + 'vitest/require-hook': RequireHookRuleConfig; +} diff --git a/src/rules/vitest/require-to-throw-message.d.ts b/src/rules/vitest/require-to-throw-message.d.ts new file mode 100644 index 00000000..245fd5d8 --- /dev/null +++ b/src/rules/vitest/require-to-throw-message.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Require toThrow() to be called with an error message. + * + * @see [require-to-throw-message](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md) + */ +export type RequireToThrowMessageRuleConfig = RuleConfig<[]>; + +/** + * Require toThrow() to be called with an error message. + * + * @see [require-to-throw-message](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md) + */ +export interface RequireToThrowMessageRule { + /** + * Require toThrow() to be called with an error message. + * + * @see [require-to-throw-message](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md) + */ + 'vitest/require-to-throw-message': RequireToThrowMessageRuleConfig; +} diff --git a/src/rules/vitest/require-top-level-describe.d.ts b/src/rules/vitest/require-top-level-describe.d.ts new file mode 100644 index 00000000..4b013a0d --- /dev/null +++ b/src/rules/vitest/require-top-level-describe.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface RequireTopLevelDescribeOption { + maxNumberOfTopLevelDescribes?: number; +} + +/** + * Options. + */ +export type RequireTopLevelDescribeOptions = [RequireTopLevelDescribeOption?]; + +/** + * Enforce that all tests are in a top-level describe. + * + * @see [require-top-level-describe](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md) + */ +export type RequireTopLevelDescribeRuleConfig = + RuleConfig; + +/** + * Enforce that all tests are in a top-level describe. + * + * @see [require-top-level-describe](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md) + */ +export interface RequireTopLevelDescribeRule { + /** + * Enforce that all tests are in a top-level describe. + * + * @see [require-top-level-describe](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md) + */ + 'vitest/require-top-level-describe': RequireTopLevelDescribeRuleConfig; +} diff --git a/src/rules/vitest/valid-describe-callback.d.ts b/src/rules/vitest/valid-describe-callback.d.ts new file mode 100644 index 00000000..43a317b7 --- /dev/null +++ b/src/rules/vitest/valid-describe-callback.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce valid describe callback. + * + * @see [valid-describe-callback](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md) + */ +export type ValidDescribeCallbackRuleConfig = RuleConfig<[]>; + +/** + * Enforce valid describe callback. + * + * @see [valid-describe-callback](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md) + */ +export interface ValidDescribeCallbackRule { + /** + * Enforce valid describe callback. + * + * @see [valid-describe-callback](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md) + */ + 'vitest/valid-describe-callback': ValidDescribeCallbackRuleConfig; +} diff --git a/src/rules/vitest/valid-expect.d.ts b/src/rules/vitest/valid-expect.d.ts new file mode 100644 index 00000000..e04b2be7 --- /dev/null +++ b/src/rules/vitest/valid-expect.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ValidExpectOption { + alwaysAwait?: boolean; + asyncMatchers?: string[]; + minArgs?: number; + maxArgs?: number; +} + +/** + * Options. + */ +export type ValidExpectOptions = [ValidExpectOption?]; + +/** + * Enforce valid `expect()` usage. + * + * @see [valid-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md) + */ +export type ValidExpectRuleConfig = RuleConfig; + +/** + * Enforce valid `expect()` usage. + * + * @see [valid-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md) + */ +export interface ValidExpectRule { + /** + * Enforce valid `expect()` usage. + * + * @see [valid-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md) + */ + 'vitest/valid-expect': ValidExpectRuleConfig; +} diff --git a/src/rules/vitest/valid-title.d.ts b/src/rules/vitest/valid-title.d.ts new file mode 100644 index 00000000..83c707bd --- /dev/null +++ b/src/rules/vitest/valid-title.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ValidTitleOption { + ignoreTypeOfDescribeName?: boolean; + disallowedWords?: string[]; + /** + */ + [k: string]: any; +} + +/** + * Options. + */ +export type ValidTitleOptions = [ValidTitleOption?]; + +/** + * Enforce valid titles. + * + * @see [valid-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md) + */ +export type ValidTitleRuleConfig = RuleConfig; + +/** + * Enforce valid titles. + * + * @see [valid-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md) + */ +export interface ValidTitleRule { + /** + * Enforce valid titles. + * + * @see [valid-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md) + */ + 'vitest/valid-title': ValidTitleRuleConfig; +}