-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Testing library (#195)
Co-authored-by: Shinigami92 <[email protected]>
- Loading branch information
1 parent
fcb34cf
commit ec647b2
Showing
36 changed files
with
855 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Record<string, unknown>> { | ||
/** | ||
* @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'>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ConsistentDataTestidOptions>; | ||
|
||
/** | ||
* 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<NoAwaitSyncEventsOptions>; | ||
|
||
/** | ||
* 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.