Skip to content

Commit

Permalink
feat: add support for @marko/testing-library (testing-library#572)
Browse files Browse the repository at this point in the history
* feat: add support for @marko/testing-library

* feat: add tests and update documentation for @marko/testing-library

* fix: run prettier and update readme

* test: add tests for @marko/testing-library

* test: add marko tests for await-async-query-test

* chore: address review comment

* test: add marko await fire-event test case

* test: add test for no-await-sync-query

* test: no container

* test: no-debugging-utils

* test: no-dom-import

* test: no-node-access

* test: no unnecassary act

* test: no-wait-for-empty-callback

* test: no-wait-for-multiple-assertions

* test: no-wait-for-side-effects

* test: prefer-query-by-disappearance

* test: prefer-screen-queries

* test: render-result-naming-convention

* fix: update no-dom-import rule to report the right module name

* fix: address PR comments

* fix: update Marko's brand logo
  • Loading branch information
PrashantAshok authored May 11, 2022
1 parent 6148c6b commit e332173
Show file tree
Hide file tree
Showing 52 changed files with 749 additions and 177 deletions.
76 changes: 45 additions & 31 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/rules/await-fire-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ methods.
>
> - `@testing-library/vue` (supported by this plugin)
> - `@testing-library/svelte` (not supported yet by this plugin)
> - `@marko/testing-library` (supported by this plugin)
Examples of **incorrect** code for this rule:

Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-dom-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ With the configuration above, if the user imports from `@testing-library/dom` or
- [Angular Testing Library API](https://testing-library.com/docs/angular-testing-library/api)
- [React Testing Library API](https://testing-library.com/docs/react-testing-library/api)
- [Vue Testing Library API](https://testing-library.com/docs/vue-testing-library/api)
- [Marko Testing Library API](https://testing-library.com/docs/marko-testing-library/api)
1 change: 1 addition & 0 deletions docs/rules/no-unnecessary-act.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
> - `@testing-library/react` (supported by this plugin)
> - `@testing-library/preact` (not supported yet by this plugin)
> - `@testing-library/svelte` (not supported yet by this plugin)
> - `@marko/testing-library` (supported by this plugin)
## Rule Details

Expand Down
29 changes: 29 additions & 0 deletions lib/configs/marko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-query': 'error',
'testing-library/await-async-utils': 'error',
'testing-library/await-fire-event': 'error',
'testing-library/no-await-sync-query': 'error',
'testing-library/no-container': 'error',
'testing-library/no-debugging-utils': 'error',
'testing-library/no-dom-import': ['error', 'marko'],
'testing-library/no-node-access': 'error',
'testing-library/no-promise-in-fire-event': 'error',
'testing-library/no-render-in-setup': 'error',
'testing-library/no-unnecessary-act': 'error',
'testing-library/no-wait-for-empty-callback': 'error',
'testing-library/no-wait-for-multiple-assertions': 'error',
'testing-library/no-wait-for-side-effects': 'error',
'testing-library/no-wait-for-snapshot': 'error',
'testing-library/prefer-find-by': 'error',
'testing-library/prefer-presence-queries': 'error',
'testing-library/prefer-query-by-disappearance': 'error',
'testing-library/prefer-screen-queries': 'error',
'testing-library/render-result-naming-convention': 'error',
},
};
1 change: 1 addition & 0 deletions lib/rules/await-async-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/await-async-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/await-fire-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/consistent-data-testid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-await-sync-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-await-sync-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-debugging-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
7 changes: 6 additions & 1 deletion lib/rules/no-dom-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: ['error', 'angular'],
react: ['error', 'react'],
vue: ['error', 'vue'],
marko: ['error', 'marko'],
},
},
messages: {
Expand All @@ -46,7 +47,11 @@ export default createTestingLibraryRule<Options, MessageIds>({
moduleName: string
) {
if (framework) {
const correctModuleName = moduleName.replace('dom', framework);
// marko TL is called @marko/testing-library
const correctModuleName =
framework === 'marko'
? moduleName.replace('dom-', `@${framework}/`)
: moduleName.replace('dom', framework);
context.report({
node,
messageId: 'noDomImportFramework',
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-global-regexp-flag-in-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-manual-cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-node-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-promise-in-fire-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-render-in-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-unnecessary-act.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: 'error',
vue: false,
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-empty-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-multiple-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-side-effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-explicit-assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-find-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-presence-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-query-by-disappearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-screen-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-user-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-wait-for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/render-result-naming-convention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error',
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const LIBRARY_MODULES = [
'@testing-library/preact',
'@testing-library/vue',
'@testing-library/svelte',
'@marko/testing-library',
];

const SYNC_QUERIES_VARIANTS = ['getBy', 'getAllBy', 'queryBy', 'queryAllBy'];
Expand Down
1 change: 1 addition & 0 deletions lib/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const SUPPORTED_TESTING_FRAMEWORKS = [
'angular',
'react',
'vue',
'marko',
] as const;
export type SupportedTestingFramework =
typeof SUPPORTED_TESTING_FRAMEWORKS[number];
30 changes: 30 additions & 0 deletions tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ Object {
"testing-library/prefer-screen-queries": "error",
},
},
"marko": Object {
"plugins": Array [
"testing-library",
],
"rules": Object {
"testing-library/await-async-query": "error",
"testing-library/await-async-utils": "error",
"testing-library/await-fire-event": "error",
"testing-library/no-await-sync-query": "error",
"testing-library/no-container": "error",
"testing-library/no-debugging-utils": "error",
"testing-library/no-dom-import": Array [
"error",
"marko",
],
"testing-library/no-node-access": "error",
"testing-library/no-promise-in-fire-event": "error",
"testing-library/no-render-in-setup": "error",
"testing-library/no-unnecessary-act": "error",
"testing-library/no-wait-for-empty-callback": "error",
"testing-library/no-wait-for-multiple-assertions": "error",
"testing-library/no-wait-for-side-effects": "error",
"testing-library/no-wait-for-snapshot": "error",
"testing-library/prefer-find-by": "error",
"testing-library/prefer-presence-queries": "error",
"testing-library/prefer-query-by-disappearance": "error",
"testing-library/prefer-screen-queries": "error",
"testing-library/render-result-naming-convention": "error",
},
},
"react": Object {
"plugins": Array [
"testing-library",
Expand Down
Loading

0 comments on commit e332173

Please sign in to comment.