From ab7bc9131c8e882b6e4c3219abcdbe2031afbf79 Mon Sep 17 00:00:00 2001 From: Azat S Date: Tue, 25 Apr 2023 21:51:07 +0300 Subject: [PATCH 1/2] Add support for Testing library --- package.json | 1 + pnpm-lock.yaml | 16 +++++ .../generate-rule-files/src/plugins-map.ts | 4 ++ .../testing-library/await-async-query.d.ts | 22 +++++++ .../testing-library/await-async-utils.d.ts | 22 +++++++ .../testing-library/await-fire-event.d.ts | 22 +++++++ .../consistent-data-testid.d.ts | 37 ++++++++++++ src/rules/testing-library/index.d.ts | 58 +++++++++++++++++++ .../testing-library/no-await-sync-events.d.ts | 40 +++++++++++++ .../testing-library/no-await-sync-query.d.ts | 22 +++++++ src/rules/testing-library/no-container.d.ts | 22 +++++++ .../testing-library/no-debugging-utils.d.ts | 41 +++++++++++++ src/rules/testing-library/no-dom-import.d.ts | 32 ++++++++++ .../no-global-regexp-flag-in-query.d.ts | 22 +++++++ .../testing-library/no-manual-cleanup.d.ts | 22 +++++++ src/rules/testing-library/no-node-access.d.ts | 35 +++++++++++ .../no-promise-in-fire-event.d.ts | 22 +++++++ .../testing-library/no-render-in-setup.d.ts | 35 +++++++++++ .../testing-library/no-unnecessary-act.d.ts | 35 +++++++++++ .../no-wait-for-empty-callback.d.ts | 22 +++++++ .../no-wait-for-multiple-assertions.d.ts | 22 +++++++ .../no-wait-for-side-effects.d.ts | 22 +++++++ .../testing-library/no-wait-for-snapshot.d.ts | 22 +++++++ .../prefer-explicit-assert.d.ts | 36 ++++++++++++ src/rules/testing-library/prefer-find-by.d.ts | 22 +++++++ .../prefer-presence-queries.d.ts | 36 ++++++++++++ .../prefer-query-by-disappearance.d.ts | 22 +++++++ .../prefer-screen-queries.d.ts | 22 +++++++ .../testing-library/prefer-user-event.d.ts | 35 +++++++++++ .../testing-library/prefer-wait-for.d.ts | 22 +++++++ .../render-result-naming-convention.d.ts | 22 +++++++ 31 files changed, 815 insertions(+) create mode 100644 src/rules/testing-library/await-async-query.d.ts create mode 100644 src/rules/testing-library/await-async-utils.d.ts create mode 100644 src/rules/testing-library/await-fire-event.d.ts create mode 100644 src/rules/testing-library/consistent-data-testid.d.ts create mode 100644 src/rules/testing-library/index.d.ts create mode 100644 src/rules/testing-library/no-await-sync-events.d.ts create mode 100644 src/rules/testing-library/no-await-sync-query.d.ts create mode 100644 src/rules/testing-library/no-container.d.ts create mode 100644 src/rules/testing-library/no-debugging-utils.d.ts create mode 100644 src/rules/testing-library/no-dom-import.d.ts create mode 100644 src/rules/testing-library/no-global-regexp-flag-in-query.d.ts create mode 100644 src/rules/testing-library/no-manual-cleanup.d.ts create mode 100644 src/rules/testing-library/no-node-access.d.ts create mode 100644 src/rules/testing-library/no-promise-in-fire-event.d.ts create mode 100644 src/rules/testing-library/no-render-in-setup.d.ts create mode 100644 src/rules/testing-library/no-unnecessary-act.d.ts create mode 100644 src/rules/testing-library/no-wait-for-empty-callback.d.ts create mode 100644 src/rules/testing-library/no-wait-for-multiple-assertions.d.ts create mode 100644 src/rules/testing-library/no-wait-for-side-effects.d.ts create mode 100644 src/rules/testing-library/no-wait-for-snapshot.d.ts create mode 100644 src/rules/testing-library/prefer-explicit-assert.d.ts create mode 100644 src/rules/testing-library/prefer-find-by.d.ts create mode 100644 src/rules/testing-library/prefer-presence-queries.d.ts create mode 100644 src/rules/testing-library/prefer-query-by-disappearance.d.ts create mode 100644 src/rules/testing-library/prefer-screen-queries.d.ts create mode 100644 src/rules/testing-library/prefer-user-event.d.ts create mode 100644 src/rules/testing-library/prefer-wait-for.d.ts create mode 100644 src/rules/testing-library/render-result-naming-convention.d.ts diff --git a/package.json b/package.json index efd7ee0c..16b91a4c 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ "eslint-plugin-react-hooks": "~4.6.0", "eslint-plugin-sonarjs": "~0.19.0", "eslint-plugin-spellcheck": "~0.0.20", + "eslint-plugin-testing-library": "~5.10.3", "eslint-plugin-unicorn": "~46.0.0", "eslint-plugin-vitest": "~0.1.4", "eslint-plugin-vue": "~9.11.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 84f8d64d..88ca4971 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,6 +88,9 @@ devDependencies: eslint-plugin-spellcheck: specifier: ~0.0.20 version: 0.0.20(eslint@8.39.0) + eslint-plugin-testing-library: + specifier: ~5.10.3 + version: 5.10.3(eslint@8.39.0)(typescript@5.0.4) eslint-plugin-unicorn: specifier: ~46.0.0 version: 46.0.0(eslint@8.39.0) @@ -2566,6 +2569,19 @@ packages: lodash: 4.17.21 dev: true + /eslint-plugin-testing-library@5.10.3(eslint@8.39.0)(typescript@5.0.4): + resolution: {integrity: sha512-0yhsKFsjHLud5PM+f2dWr9K3rqYzMy4cSHs3lcmFYMa1CdSzRvHGgXvsFarBjZ41gU8jhTdMIkg8jHLxGJqLqw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0, npm: '>=6'} + peerDependencies: + eslint: ^7.5.0 || ^8.0.0 + dependencies: + '@typescript-eslint/utils': 5.59.0(eslint@8.39.0)(typescript@5.0.4) + eslint: 8.39.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /eslint-plugin-unicorn@46.0.0(eslint@8.39.0): resolution: {integrity: sha512-j07WkC+PFZwk8J33LYp6JMoHa1lXc1u6R45pbSAipjpfpb7KIGr17VE2D685zCxR5VL4cjrl65kTJflziQWMDA==} engines: {node: '>=14.18'} diff --git a/scripts/generate-rule-files/src/plugins-map.ts b/scripts/generate-rule-files/src/plugins-map.ts index 7238d7f1..1e556c22 100644 --- a/scripts/generate-rule-files/src/plugins-map.ts +++ b/scripts/generate-rule-files/src/plugins-map.ts @@ -76,6 +76,10 @@ export const PLUGIN_REGISTRY: Readonly> = { name: 'Spellcheck', module: 'eslint-plugin-spellcheck', }, + 'testing-library': { + name: 'TestingLibrary', + module: 'eslint-plugin-testing-library', + }, unicorn: { name: 'Unicorn', module: 'eslint-plugin-unicorn', diff --git a/src/rules/testing-library/await-async-query.d.ts b/src/rules/testing-library/await-async-query.d.ts new file mode 100644 index 00000000..517896d6 --- /dev/null +++ b/src/rules/testing-library/await-async-query.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce promises from async queries to be handled. + * + * @see [await-async-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-query.md) + */ +export type AwaitAsyncQueryRuleConfig = RuleConfig<[]>; + +/** + * Enforce promises from async queries to be handled. + * + * @see [await-async-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-query.md) + */ +export interface AwaitAsyncQueryRule { + /** + * Enforce promises from async queries to be handled. + * + * @see [await-async-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-query.md) + */ + 'testing-library/await-async-query': AwaitAsyncQueryRuleConfig; +} diff --git a/src/rules/testing-library/await-async-utils.d.ts b/src/rules/testing-library/await-async-utils.d.ts new file mode 100644 index 00000000..dbd3505c --- /dev/null +++ b/src/rules/testing-library/await-async-utils.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce promises from async utils to be awaited properly. + * + * @see [await-async-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-utils.md) + */ +export type AwaitAsyncUtilsRuleConfig = RuleConfig<[]>; + +/** + * Enforce promises from async utils to be awaited properly. + * + * @see [await-async-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-utils.md) + */ +export interface AwaitAsyncUtilsRule { + /** + * Enforce promises from async utils to be awaited properly. + * + * @see [await-async-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-utils.md) + */ + 'testing-library/await-async-utils': AwaitAsyncUtilsRuleConfig; +} diff --git a/src/rules/testing-library/await-fire-event.d.ts b/src/rules/testing-library/await-fire-event.d.ts new file mode 100644 index 00000000..dde9b6cc --- /dev/null +++ b/src/rules/testing-library/await-fire-event.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce promises from `fireEvent` methods to be handled. + * + * @see [await-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-fire-event.md) + */ +export type AwaitFireEventRuleConfig = RuleConfig<[]>; + +/** + * Enforce promises from `fireEvent` methods to be handled. + * + * @see [await-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-fire-event.md) + */ +export interface AwaitFireEventRule { + /** + * Enforce promises from `fireEvent` methods to be handled. + * + * @see [await-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-fire-event.md) + */ + 'testing-library/await-fire-event': AwaitFireEventRuleConfig; +} diff --git a/src/rules/testing-library/consistent-data-testid.d.ts b/src/rules/testing-library/consistent-data-testid.d.ts new file mode 100644 index 00000000..b7dbd947 --- /dev/null +++ b/src/rules/testing-library/consistent-data-testid.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ConsistentDataTestidOption { + testIdPattern: string; + testIdAttribute?: string | string[]; + customMessage?: string; +} + +/** + * Options. + */ +export type ConsistentDataTestidOptions = [ConsistentDataTestidOption?]; + +/** + * Ensures consistent usage of `data-testid`. + * + * @see [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/consistent-data-testid.md) + */ +export type ConsistentDataTestidRuleConfig = + RuleConfig; + +/** + * Ensures consistent usage of `data-testid`. + * + * @see [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/consistent-data-testid.md) + */ +export interface ConsistentDataTestidRule { + /** + * Ensures consistent usage of `data-testid`. + * + * @see [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/consistent-data-testid.md) + */ + 'testing-library/consistent-data-testid': ConsistentDataTestidRuleConfig; +} diff --git a/src/rules/testing-library/index.d.ts b/src/rules/testing-library/index.d.ts new file mode 100644 index 00000000..4762596e --- /dev/null +++ b/src/rules/testing-library/index.d.ts @@ -0,0 +1,58 @@ +import type { AwaitAsyncQueryRule } from './await-async-query'; +import type { AwaitAsyncUtilsRule } from './await-async-utils'; +import type { AwaitFireEventRule } from './await-fire-event'; +import type { ConsistentDataTestidRule } from './consistent-data-testid'; +import type { NoAwaitSyncEventsRule } from './no-await-sync-events'; +import type { NoAwaitSyncQueryRule } from './no-await-sync-query'; +import type { NoContainerRule } from './no-container'; +import type { NoDebuggingUtilsRule } from './no-debugging-utils'; +import type { NoDomImportRule } from './no-dom-import'; +import type { NoGlobalRegexpFlagInQueryRule } from './no-global-regexp-flag-in-query'; +import type { NoManualCleanupRule } from './no-manual-cleanup'; +import type { NoNodeAccessRule } from './no-node-access'; +import type { NoPromiseInFireEventRule } from './no-promise-in-fire-event'; +import type { NoRenderInSetupRule } from './no-render-in-setup'; +import type { NoUnnecessaryActRule } from './no-unnecessary-act'; +import type { NoWaitForEmptyCallbackRule } from './no-wait-for-empty-callback'; +import type { NoWaitForMultipleAssertionsRule } from './no-wait-for-multiple-assertions'; +import type { NoWaitForSideEffectsRule } from './no-wait-for-side-effects'; +import type { NoWaitForSnapshotRule } from './no-wait-for-snapshot'; +import type { PreferExplicitAssertRule } from './prefer-explicit-assert'; +import type { PreferFindByRule } from './prefer-find-by'; +import type { PreferPresenceQueriesRule } from './prefer-presence-queries'; +import type { PreferQueryByDisappearanceRule } from './prefer-query-by-disappearance'; +import type { PreferScreenQueriesRule } from './prefer-screen-queries'; +import type { PreferUserEventRule } from './prefer-user-event'; +import type { PreferWaitForRule } from './prefer-wait-for'; +import type { RenderResultNamingConventionRule } from './render-result-naming-convention'; + +/** + * All TestingLibrary rules. + */ +export type TestingLibraryRules = AwaitAsyncQueryRule & + AwaitAsyncUtilsRule & + AwaitFireEventRule & + ConsistentDataTestidRule & + NoAwaitSyncEventsRule & + NoAwaitSyncQueryRule & + NoContainerRule & + NoDebuggingUtilsRule & + NoDomImportRule & + NoGlobalRegexpFlagInQueryRule & + NoManualCleanupRule & + NoNodeAccessRule & + NoPromiseInFireEventRule & + NoRenderInSetupRule & + NoUnnecessaryActRule & + NoWaitForEmptyCallbackRule & + NoWaitForMultipleAssertionsRule & + NoWaitForSideEffectsRule & + NoWaitForSnapshotRule & + PreferExplicitAssertRule & + PreferFindByRule & + PreferPresenceQueriesRule & + PreferQueryByDisappearanceRule & + PreferScreenQueriesRule & + PreferUserEventRule & + PreferWaitForRule & + RenderResultNamingConventionRule; diff --git a/src/rules/testing-library/no-await-sync-events.d.ts b/src/rules/testing-library/no-await-sync-events.d.ts new file mode 100644 index 00000000..f9285bf9 --- /dev/null +++ b/src/rules/testing-library/no-await-sync-events.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoAwaitSyncEventsOption { + /** + * @minItems 1 + */ + eventModules?: [ + 'fire-event' | 'user-event', + ...('fire-event' | 'user-event')[], + ]; +} + +/** + * Options. + */ +export type NoAwaitSyncEventsOptions = [NoAwaitSyncEventsOption?]; + +/** + * Disallow unnecessary `await` for sync events. + * + * @see [no-await-sync-events](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-events.md) + */ +export type NoAwaitSyncEventsRuleConfig = RuleConfig; + +/** + * Disallow unnecessary `await` for sync events. + * + * @see [no-await-sync-events](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-events.md) + */ +export interface NoAwaitSyncEventsRule { + /** + * Disallow unnecessary `await` for sync events. + * + * @see [no-await-sync-events](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-events.md) + */ + 'testing-library/no-await-sync-events': NoAwaitSyncEventsRuleConfig; +} diff --git a/src/rules/testing-library/no-await-sync-query.d.ts b/src/rules/testing-library/no-await-sync-query.d.ts new file mode 100644 index 00000000..3c5c54c7 --- /dev/null +++ b/src/rules/testing-library/no-await-sync-query.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow unnecessary `await` for sync queries. + * + * @see [no-await-sync-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-query.md) + */ +export type NoAwaitSyncQueryRuleConfig = RuleConfig<[]>; + +/** + * Disallow unnecessary `await` for sync queries. + * + * @see [no-await-sync-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-query.md) + */ +export interface NoAwaitSyncQueryRule { + /** + * Disallow unnecessary `await` for sync queries. + * + * @see [no-await-sync-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-query.md) + */ + 'testing-library/no-await-sync-query': NoAwaitSyncQueryRuleConfig; +} diff --git a/src/rules/testing-library/no-container.d.ts b/src/rules/testing-library/no-container.d.ts new file mode 100644 index 00000000..a5653159 --- /dev/null +++ b/src/rules/testing-library/no-container.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of `container` methods. + * + * @see [no-container](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-container.md) + */ +export type NoContainerRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of `container` methods. + * + * @see [no-container](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-container.md) + */ +export interface NoContainerRule { + /** + * Disallow the use of `container` methods. + * + * @see [no-container](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-container.md) + */ + 'testing-library/no-container': NoContainerRuleConfig; +} diff --git a/src/rules/testing-library/no-debugging-utils.d.ts b/src/rules/testing-library/no-debugging-utils.d.ts new file mode 100644 index 00000000..615be86a --- /dev/null +++ b/src/rules/testing-library/no-debugging-utils.d.ts @@ -0,0 +1,41 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoDebuggingUtilsOption { + utilsToCheckFor?: { + prettyFormat?: boolean; + logDOM?: boolean; + logRoles?: boolean; + prettyDOM?: boolean; + logTestingPlaygroundURL?: boolean; + debug?: boolean; + }; +} + +/** + * Options. + */ +export type NoDebuggingUtilsOptions = [NoDebuggingUtilsOption?]; + +/** + * Disallow the use of debugging utilities like `debug`. + * + * @see [no-debugging-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-debugging-utils.md) + */ +export type NoDebuggingUtilsRuleConfig = RuleConfig; + +/** + * Disallow the use of debugging utilities like `debug`. + * + * @see [no-debugging-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-debugging-utils.md) + */ +export interface NoDebuggingUtilsRule { + /** + * Disallow the use of debugging utilities like `debug`. + * + * @see [no-debugging-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-debugging-utils.md) + */ + 'testing-library/no-debugging-utils': NoDebuggingUtilsRuleConfig; +} diff --git a/src/rules/testing-library/no-dom-import.d.ts b/src/rules/testing-library/no-dom-import.d.ts new file mode 100644 index 00000000..f154548f --- /dev/null +++ b/src/rules/testing-library/no-dom-import.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoDomImportOption = string; + +/** + * Options. + */ +export type NoDomImportOptions = [NoDomImportOption?]; + +/** + * Disallow importing from DOM Testing Library. + * + * @see [no-dom-import](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-dom-import.md) + */ +export type NoDomImportRuleConfig = RuleConfig; + +/** + * Disallow importing from DOM Testing Library. + * + * @see [no-dom-import](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-dom-import.md) + */ +export interface NoDomImportRule { + /** + * Disallow importing from DOM Testing Library. + * + * @see [no-dom-import](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-dom-import.md) + */ + 'testing-library/no-dom-import': NoDomImportRuleConfig; +} diff --git a/src/rules/testing-library/no-global-regexp-flag-in-query.d.ts b/src/rules/testing-library/no-global-regexp-flag-in-query.d.ts new file mode 100644 index 00000000..c8af72d3 --- /dev/null +++ b/src/rules/testing-library/no-global-regexp-flag-in-query.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of the global RegExp flag (/g) in queries. + * + * @see [no-global-regexp-flag-in-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-global-regexp-flag-in-query.md) + */ +export type NoGlobalRegexpFlagInQueryRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of the global RegExp flag (/g) in queries. + * + * @see [no-global-regexp-flag-in-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-global-regexp-flag-in-query.md) + */ +export interface NoGlobalRegexpFlagInQueryRule { + /** + * Disallow the use of the global RegExp flag (/g) in queries. + * + * @see [no-global-regexp-flag-in-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-global-regexp-flag-in-query.md) + */ + 'testing-library/no-global-regexp-flag-in-query': NoGlobalRegexpFlagInQueryRuleConfig; +} diff --git a/src/rules/testing-library/no-manual-cleanup.d.ts b/src/rules/testing-library/no-manual-cleanup.d.ts new file mode 100644 index 00000000..c13de672 --- /dev/null +++ b/src/rules/testing-library/no-manual-cleanup.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of `cleanup`. + * + * @see [no-manual-cleanup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-manual-cleanup.md) + */ +export type NoManualCleanupRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of `cleanup`. + * + * @see [no-manual-cleanup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-manual-cleanup.md) + */ +export interface NoManualCleanupRule { + /** + * Disallow the use of `cleanup`. + * + * @see [no-manual-cleanup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-manual-cleanup.md) + */ + 'testing-library/no-manual-cleanup': NoManualCleanupRuleConfig; +} diff --git a/src/rules/testing-library/no-node-access.d.ts b/src/rules/testing-library/no-node-access.d.ts new file mode 100644 index 00000000..e18ffb01 --- /dev/null +++ b/src/rules/testing-library/no-node-access.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoNodeAccessOption { + allowContainerFirstChild?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type NoNodeAccessOptions = [NoNodeAccessOption?]; + +/** + * Disallow direct Node access. + * + * @see [no-node-access](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-node-access.md) + */ +export type NoNodeAccessRuleConfig = RuleConfig; + +/** + * Disallow direct Node access. + * + * @see [no-node-access](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-node-access.md) + */ +export interface NoNodeAccessRule { + /** + * Disallow direct Node access. + * + * @see [no-node-access](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-node-access.md) + */ + 'testing-library/no-node-access': NoNodeAccessRuleConfig; +} diff --git a/src/rules/testing-library/no-promise-in-fire-event.d.ts b/src/rules/testing-library/no-promise-in-fire-event.d.ts new file mode 100644 index 00000000..c520f838 --- /dev/null +++ b/src/rules/testing-library/no-promise-in-fire-event.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of promises passed to a `fireEvent` method. + * + * @see [no-promise-in-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-promise-in-fire-event.md) + */ +export type NoPromiseInFireEventRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of promises passed to a `fireEvent` method. + * + * @see [no-promise-in-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-promise-in-fire-event.md) + */ +export interface NoPromiseInFireEventRule { + /** + * Disallow the use of promises passed to a `fireEvent` method. + * + * @see [no-promise-in-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-promise-in-fire-event.md) + */ + 'testing-library/no-promise-in-fire-event': NoPromiseInFireEventRuleConfig; +} diff --git a/src/rules/testing-library/no-render-in-setup.d.ts b/src/rules/testing-library/no-render-in-setup.d.ts new file mode 100644 index 00000000..4ecaa384 --- /dev/null +++ b/src/rules/testing-library/no-render-in-setup.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoRenderInSetupOption { + allowTestingFrameworkSetupHook?: 'beforeEach' | 'beforeAll'; + [k: string]: any; +} + +/** + * Options. + */ +export type NoRenderInSetupOptions = [NoRenderInSetupOption?]; + +/** + * Disallow the use of `render` in testing frameworks setup functions. + * + * @see [no-render-in-setup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-render-in-setup.md) + */ +export type NoRenderInSetupRuleConfig = RuleConfig; + +/** + * Disallow the use of `render` in testing frameworks setup functions. + * + * @see [no-render-in-setup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-render-in-setup.md) + */ +export interface NoRenderInSetupRule { + /** + * Disallow the use of `render` in testing frameworks setup functions. + * + * @see [no-render-in-setup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-render-in-setup.md) + */ + 'testing-library/no-render-in-setup': NoRenderInSetupRuleConfig; +} diff --git a/src/rules/testing-library/no-unnecessary-act.d.ts b/src/rules/testing-library/no-unnecessary-act.d.ts new file mode 100644 index 00000000..0fb2bfdc --- /dev/null +++ b/src/rules/testing-library/no-unnecessary-act.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUnnecessaryActOption { + isStrict?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type NoUnnecessaryActOptions = [NoUnnecessaryActOption?]; + +/** + * Disallow wrapping Testing Library utils or empty callbacks in `act`. + * + * @see [no-unnecessary-act](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-unnecessary-act.md) + */ +export type NoUnnecessaryActRuleConfig = RuleConfig; + +/** + * Disallow wrapping Testing Library utils or empty callbacks in `act`. + * + * @see [no-unnecessary-act](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-unnecessary-act.md) + */ +export interface NoUnnecessaryActRule { + /** + * Disallow wrapping Testing Library utils or empty callbacks in `act`. + * + * @see [no-unnecessary-act](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-unnecessary-act.md) + */ + 'testing-library/no-unnecessary-act': NoUnnecessaryActRuleConfig; +} diff --git a/src/rules/testing-library/no-wait-for-empty-callback.d.ts b/src/rules/testing-library/no-wait-for-empty-callback.d.ts new file mode 100644 index 00000000..615eddd0 --- /dev/null +++ b/src/rules/testing-library/no-wait-for-empty-callback.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved`. + * + * @see [no-wait-for-empty-callback](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-empty-callback.md) + */ +export type NoWaitForEmptyCallbackRuleConfig = RuleConfig<[]>; + +/** + * Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved`. + * + * @see [no-wait-for-empty-callback](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-empty-callback.md) + */ +export interface NoWaitForEmptyCallbackRule { + /** + * Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved`. + * + * @see [no-wait-for-empty-callback](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-empty-callback.md) + */ + 'testing-library/no-wait-for-empty-callback': NoWaitForEmptyCallbackRuleConfig; +} diff --git a/src/rules/testing-library/no-wait-for-multiple-assertions.d.ts b/src/rules/testing-library/no-wait-for-multiple-assertions.d.ts new file mode 100644 index 00000000..d7994f23 --- /dev/null +++ b/src/rules/testing-library/no-wait-for-multiple-assertions.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of multiple `expect` calls inside `waitFor`. + * + * @see [no-wait-for-multiple-assertions](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-multiple-assertions.md) + */ +export type NoWaitForMultipleAssertionsRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of multiple `expect` calls inside `waitFor`. + * + * @see [no-wait-for-multiple-assertions](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-multiple-assertions.md) + */ +export interface NoWaitForMultipleAssertionsRule { + /** + * Disallow the use of multiple `expect` calls inside `waitFor`. + * + * @see [no-wait-for-multiple-assertions](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-multiple-assertions.md) + */ + 'testing-library/no-wait-for-multiple-assertions': NoWaitForMultipleAssertionsRuleConfig; +} diff --git a/src/rules/testing-library/no-wait-for-side-effects.d.ts b/src/rules/testing-library/no-wait-for-side-effects.d.ts new file mode 100644 index 00000000..265c10bb --- /dev/null +++ b/src/rules/testing-library/no-wait-for-side-effects.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of side effects in `waitFor`. + * + * @see [no-wait-for-side-effects](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-side-effects.md) + */ +export type NoWaitForSideEffectsRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of side effects in `waitFor`. + * + * @see [no-wait-for-side-effects](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-side-effects.md) + */ +export interface NoWaitForSideEffectsRule { + /** + * Disallow the use of side effects in `waitFor`. + * + * @see [no-wait-for-side-effects](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-side-effects.md) + */ + 'testing-library/no-wait-for-side-effects': NoWaitForSideEffectsRuleConfig; +} diff --git a/src/rules/testing-library/no-wait-for-snapshot.d.ts b/src/rules/testing-library/no-wait-for-snapshot.d.ts new file mode 100644 index 00000000..57cfa01a --- /dev/null +++ b/src/rules/testing-library/no-wait-for-snapshot.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Ensures no snapshot is generated inside of a `waitFor` call. + * + * @see [no-wait-for-snapshot](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-snapshot.md) + */ +export type NoWaitForSnapshotRuleConfig = RuleConfig<[]>; + +/** + * Ensures no snapshot is generated inside of a `waitFor` call. + * + * @see [no-wait-for-snapshot](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-snapshot.md) + */ +export interface NoWaitForSnapshotRule { + /** + * Ensures no snapshot is generated inside of a `waitFor` call. + * + * @see [no-wait-for-snapshot](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-snapshot.md) + */ + 'testing-library/no-wait-for-snapshot': NoWaitForSnapshotRuleConfig; +} diff --git a/src/rules/testing-library/prefer-explicit-assert.d.ts b/src/rules/testing-library/prefer-explicit-assert.d.ts new file mode 100644 index 00000000..0cb9d80c --- /dev/null +++ b/src/rules/testing-library/prefer-explicit-assert.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferExplicitAssertOption { + assertion?: 'toBeInTheDocument' | 'toBeTruthy' | 'toBeDefined'; + includeFindQueries?: boolean; +} + +/** + * Options. + */ +export type PreferExplicitAssertOptions = [PreferExplicitAssertOption?]; + +/** + * Suggest using explicit assertions rather than standalone queries. + * + * @see [prefer-explicit-assert](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-explicit-assert.md) + */ +export type PreferExplicitAssertRuleConfig = + RuleConfig; + +/** + * Suggest using explicit assertions rather than standalone queries. + * + * @see [prefer-explicit-assert](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-explicit-assert.md) + */ +export interface PreferExplicitAssertRule { + /** + * Suggest using explicit assertions rather than standalone queries. + * + * @see [prefer-explicit-assert](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-explicit-assert.md) + */ + 'testing-library/prefer-explicit-assert': PreferExplicitAssertRuleConfig; +} diff --git a/src/rules/testing-library/prefer-find-by.d.ts b/src/rules/testing-library/prefer-find-by.d.ts new file mode 100644 index 00000000..4d92f9b6 --- /dev/null +++ b/src/rules/testing-library/prefer-find-by.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements. + * + * @see [prefer-find-by](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-find-by.md) + */ +export type PreferFindByRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements. + * + * @see [prefer-find-by](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-find-by.md) + */ +export interface PreferFindByRule { + /** + * Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements. + * + * @see [prefer-find-by](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-find-by.md) + */ + 'testing-library/prefer-find-by': PreferFindByRuleConfig; +} diff --git a/src/rules/testing-library/prefer-presence-queries.d.ts b/src/rules/testing-library/prefer-presence-queries.d.ts new file mode 100644 index 00000000..c45ffc7d --- /dev/null +++ b/src/rules/testing-library/prefer-presence-queries.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferPresenceQueriesOption { + presence?: boolean; + absence?: boolean; +} + +/** + * Options. + */ +export type PreferPresenceQueriesOptions = [PreferPresenceQueriesOption?]; + +/** + * Ensure appropriate `get*`/`query*` queries are used with their respective matchers. + * + * @see [prefer-presence-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-presence-queries.md) + */ +export type PreferPresenceQueriesRuleConfig = + RuleConfig; + +/** + * Ensure appropriate `get*`/`query*` queries are used with their respective matchers. + * + * @see [prefer-presence-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-presence-queries.md) + */ +export interface PreferPresenceQueriesRule { + /** + * Ensure appropriate `get*`/`query*` queries are used with their respective matchers. + * + * @see [prefer-presence-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-presence-queries.md) + */ + 'testing-library/prefer-presence-queries': PreferPresenceQueriesRuleConfig; +} diff --git a/src/rules/testing-library/prefer-query-by-disappearance.d.ts b/src/rules/testing-library/prefer-query-by-disappearance.d.ts new file mode 100644 index 00000000..460334cd --- /dev/null +++ b/src/rules/testing-library/prefer-query-by-disappearance.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `queryBy*` queries when waiting for disappearance. + * + * @see [prefer-query-by-disappearance](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-query-by-disappearance.md) + */ +export type PreferQueryByDisappearanceRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `queryBy*` queries when waiting for disappearance. + * + * @see [prefer-query-by-disappearance](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-query-by-disappearance.md) + */ +export interface PreferQueryByDisappearanceRule { + /** + * Suggest using `queryBy*` queries when waiting for disappearance. + * + * @see [prefer-query-by-disappearance](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-query-by-disappearance.md) + */ + 'testing-library/prefer-query-by-disappearance': PreferQueryByDisappearanceRuleConfig; +} diff --git a/src/rules/testing-library/prefer-screen-queries.d.ts b/src/rules/testing-library/prefer-screen-queries.d.ts new file mode 100644 index 00000000..28befb93 --- /dev/null +++ b/src/rules/testing-library/prefer-screen-queries.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Suggest using `screen` while querying. + * + * @see [prefer-screen-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-screen-queries.md) + */ +export type PreferScreenQueriesRuleConfig = RuleConfig<[]>; + +/** + * Suggest using `screen` while querying. + * + * @see [prefer-screen-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-screen-queries.md) + */ +export interface PreferScreenQueriesRule { + /** + * Suggest using `screen` while querying. + * + * @see [prefer-screen-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-screen-queries.md) + */ + 'testing-library/prefer-screen-queries': PreferScreenQueriesRuleConfig; +} diff --git a/src/rules/testing-library/prefer-user-event.d.ts b/src/rules/testing-library/prefer-user-event.d.ts new file mode 100644 index 00000000..d1ce16b1 --- /dev/null +++ b/src/rules/testing-library/prefer-user-event.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferUserEventOption { + allowedMethods?: any[]; + [k: string]: any; +} + +/** + * Options. + */ +export type PreferUserEventOptions = [PreferUserEventOption?]; + +/** + * Suggest using `userEvent` over `fireEvent` for simulating user interactions. + * + * @see [prefer-user-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-user-event.md) + */ +export type PreferUserEventRuleConfig = RuleConfig; + +/** + * Suggest using `userEvent` over `fireEvent` for simulating user interactions. + * + * @see [prefer-user-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-user-event.md) + */ +export interface PreferUserEventRule { + /** + * Suggest using `userEvent` over `fireEvent` for simulating user interactions. + * + * @see [prefer-user-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-user-event.md) + */ + 'testing-library/prefer-user-event': PreferUserEventRuleConfig; +} diff --git a/src/rules/testing-library/prefer-wait-for.d.ts b/src/rules/testing-library/prefer-wait-for.d.ts new file mode 100644 index 00000000..faf8b42d --- /dev/null +++ b/src/rules/testing-library/prefer-wait-for.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Use `waitFor` instead of deprecated wait methods. + * + * @see [prefer-wait-for](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-wait-for.md) + */ +export type PreferWaitForRuleConfig = RuleConfig<[]>; + +/** + * Use `waitFor` instead of deprecated wait methods. + * + * @see [prefer-wait-for](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-wait-for.md) + */ +export interface PreferWaitForRule { + /** + * Use `waitFor` instead of deprecated wait methods. + * + * @see [prefer-wait-for](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-wait-for.md) + */ + 'testing-library/prefer-wait-for': PreferWaitForRuleConfig; +} diff --git a/src/rules/testing-library/render-result-naming-convention.d.ts b/src/rules/testing-library/render-result-naming-convention.d.ts new file mode 100644 index 00000000..62504647 --- /dev/null +++ b/src/rules/testing-library/render-result-naming-convention.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce a valid naming for return value from `render`. + * + * @see [render-result-naming-convention](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/render-result-naming-convention.md) + */ +export type RenderResultNamingConventionRuleConfig = RuleConfig<[]>; + +/** + * Enforce a valid naming for return value from `render`. + * + * @see [render-result-naming-convention](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/render-result-naming-convention.md) + */ +export interface RenderResultNamingConventionRule { + /** + * Enforce a valid naming for return value from `render`. + * + * @see [render-result-naming-convention](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/render-result-naming-convention.md) + */ + 'testing-library/render-result-naming-convention': RenderResultNamingConventionRuleConfig; +} From 190da3d9119c9bd2dee3a4346f3ece8d4a39fafc Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Wed, 26 Apr 2023 18:52:35 +0200 Subject: [PATCH 2/2] add extends and settings --- .../eslint-plugin-testing-library.d.ts | 11 +++++++++ src/config/extends/index.d.ts | 2 ++ src/config/plugin.d.ts | 1 + src/config/settings/testing-library.d.ts | 24 +++++++++++++++++++ src/rules/index.d.ts | 2 ++ 5 files changed, 40 insertions(+) create mode 100644 src/config/extends/eslint-plugin-testing-library.d.ts create mode 100644 src/config/settings/testing-library.d.ts diff --git a/src/config/extends/eslint-plugin-testing-library.d.ts b/src/config/extends/eslint-plugin-testing-library.d.ts new file mode 100644 index 00000000..9adda0ca --- /dev/null +++ b/src/config/extends/eslint-plugin-testing-library.d.ts @@ -0,0 +1,11 @@ +/** + * Eslint TestingLibrary extensions. + * + * @see [Eslint TestingLibrary extensions](https://github.com/testing-library/eslint-plugin-testing-library) + */ +export type TestingLibraryExtensions = + | 'plugin:testing-library/angular' + | 'plugin:testing-library/dom' + | 'plugin:testing-library/marko' + | 'plugin:testing-library/react' + | 'plugin:testing-library/vue'; diff --git a/src/config/extends/index.d.ts b/src/config/extends/index.d.ts index 0b4d6c63..3d29c8af 100644 --- a/src/config/extends/index.d.ts +++ b/src/config/extends/index.d.ts @@ -13,6 +13,7 @@ import type { PromiseExtensions } from './eslint-plugin-promise'; import type { ReactExtensions } from './eslint-plugin-react'; import type { ReactHooksExtensions } from './eslint-plugin-react-hooks'; import type { SonarjsExtensions } from './eslint-plugin-sonarjs'; +import type { TestingLibraryExtensions } from './eslint-plugin-testing-library'; import type { UnicornExtensions } from './eslint-plugin-unicorn'; import type { VitestExtensions } from './eslint-plugin-vitest'; import type { VueExtensions } from './eslint-plugin-vue'; @@ -39,6 +40,7 @@ export type KnownExtensions = LiteralUnion< | ReactExtensions | ReactHooksExtensions | SonarjsExtensions + | TestingLibraryExtensions | TypescriptEslintExtensions | UnicornExtensions | VitestExtensions diff --git a/src/config/plugin.d.ts b/src/config/plugin.d.ts index 68997d53..0b277ac0 100644 --- a/src/config/plugin.d.ts +++ b/src/config/plugin.d.ts @@ -16,6 +16,7 @@ export type Plugin = LiteralUnion< | 'react' | 'sonarjs' | 'spellcheck' + | 'testing-library' | 'unicorn' | 'vitest' | 'vue' diff --git a/src/config/settings/testing-library.d.ts b/src/config/settings/testing-library.d.ts new file mode 100644 index 00000000..01c5461d --- /dev/null +++ b/src/config/settings/testing-library.d.ts @@ -0,0 +1,24 @@ +import type { LiteralUnion } from '../../utility-types'; + +/** + * Testing Library settings. + * + * @see [Testing Library settings](https://github.com/testing-library/eslint-plugin-testing-library) + */ +export interface TestingLibrarySettings + extends Partial> { + /** + * @see [testing-library/custom-queries](https://github.com/testing-library/eslint-plugin-testing-library#testing-librarycustom-queries) + */ + 'testing-library/custom-queries'?: 'off' | string[]; + + /** + * @see [testing-library/custom-renders](https://github.com/testing-library/eslint-plugin-testing-library#testing-librarycustom-renders) + */ + 'testing-library/custom-renders'?: 'off' | string[]; + + /** + * @see [testing-library/utils-module](https://github.com/testing-library/eslint-plugin-testing-library#testing-libraryutils-module) + */ + 'testing-library/utils-module'?: LiteralUnion<'off'>; +} diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index 24157cc9..70323bac 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -14,6 +14,7 @@ import type { ReactHooksRules } from './react-hooks'; import type { RuleConfig } from './rule-config'; import type { SonarJSRules } from './sonarjs'; import type { SpellcheckRules } from './spellcheck'; +import type { TestingLibraryRules } from './testing-library'; import type { TypeScriptRules } from './typescript-eslint'; import type { UnicornRules } from './unicorn'; import type { VitestRules } from './vitest'; @@ -42,6 +43,7 @@ export type Rules = Partial< ReactRules & SonarJSRules & SpellcheckRules & + TestingLibraryRules & TypeScriptRules & UnicornRules & VitestRules &