diff --git a/.eslint-doc-generatorrc.js b/.eslint-doc-generatorrc.js index 00e04ede..84262866 100644 --- a/.eslint-doc-generatorrc.js +++ b/.eslint-doc-generatorrc.js @@ -8,6 +8,7 @@ const config = { 'flat/dom', 'flat/marko', 'flat/react', + 'flat/svelte', 'flat/vue', ], postprocess: (content) => diff --git a/README.md b/README.md index 12761bc1..a472d9d2 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,35 @@ module.exports = [ ]; ``` +### Svelte + +Enforces recommended rules for Svelte Testing Library. + +To enable this configuration use the `extends` property in your +`.eslintrc.js` config file: + +```js +module.exports = { + extends: ['plugin:testing-library/svelte'], +}; +``` + +To enable this configuration with `eslint.config.js`, use +`testingLibrary.configs['flat/svelte']`: + +```js +const testingLibrary = require('eslint-plugin-testing-library'); + +module.exports = [ + { + files: [ + /* glob matching your test files */ + ], + ...testingLibrary.configs['flat/svelte'], + }, +]; +``` + ### Marko Enforces recommended rules for Marko Testing Library. @@ -293,35 +322,35 @@ module.exports = [ ⚠️ Configurations set to warn in.\ 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix). -| Name                            | Description | 💼 | ⚠️ | 🔧 | -| :------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | :------------------------------------------------------------------ | :-- | -| [await-async-events](docs/rules/await-async-events.md) | Enforce promises from async event methods are handled | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | 🔧 | -| [await-async-queries](docs/rules/await-async-queries.md) | Enforce promises from async queries to be handled | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [await-async-utils](docs/rules/await-async-utils.md) | Enforce promises from async utils to be awaited properly | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensures consistent usage of `data-testid` | | | | -| [no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | ![badge-angular][] ![badge-dom][] ![badge-react][] | | | -| [no-await-sync-queries](docs/rules/no-await-sync-queries.md) | Disallow unnecessary `await` for sync queries | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-debugging-utils](docs/rules/no-debugging-utils.md) | Disallow the use of debugging utilities like `debug` | | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | -| [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | 🔧 | -| [no-global-regexp-flag-in-query](docs/rules/no-global-regexp-flag-in-query.md) | Disallow the use of the global RegExp flag (/g) in queries | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | 🔧 | -| [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | ![badge-react][] ![badge-vue][] | | | -| [no-node-access](docs/rules/no-node-access.md) | Disallow direct Node access | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-promise-in-fire-event](docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-render-in-lifecycle](docs/rules/no-render-in-lifecycle.md) | Disallow the use of `render` in testing frameworks setup functions | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-unnecessary-act](docs/rules/no-unnecessary-act.md) | Disallow wrapping Testing Library utils or empty callbacks in `act` | ![badge-marko][] ![badge-react][] | | | -| [no-wait-for-multiple-assertions](docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple `expect` calls inside `waitFor` | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-wait-for-side-effects](docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | -| [prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | 🔧 | -| [prefer-implicit-assert](docs/rules/prefer-implicit-assert.md) | Suggest using implicit assertions for getBy* & findBy* queries | | | | -| [prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [prefer-query-by-disappearance](docs/rules/prefer-query-by-disappearance.md) | Suggest using `queryBy*` queries when waiting for disappearance | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [prefer-query-matchers](docs/rules/prefer-query-matchers.md) | Ensure the configured `get*`/`query*` query is used with the corresponding matchers | | | | -| [prefer-screen-queries](docs/rules/prefer-screen-queries.md) | Suggest using `screen` while querying | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | -| [prefer-user-event](docs/rules/prefer-user-event.md) | Suggest using `userEvent` over `fireEvent` for simulating user interactions | | | | -| [render-result-naming-convention](docs/rules/render-result-naming-convention.md) | Enforce a valid naming for return value from `render` | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-vue][] | | | +| Name                            | Description | 💼 | ⚠️ | 🔧 | +| :------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ | :-- | +| [await-async-events](docs/rules/await-async-events.md) | Enforce promises from async event methods are handled | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | 🔧 | +| [await-async-queries](docs/rules/await-async-queries.md) | Enforce promises from async queries to be handled | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [await-async-utils](docs/rules/await-async-utils.md) | Enforce promises from async utils to be awaited properly | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensures consistent usage of `data-testid` | | | | +| [no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | ![badge-angular][] ![badge-dom][] ![badge-react][] | | | +| [no-await-sync-queries](docs/rules/no-await-sync-queries.md) | Disallow unnecessary `await` for sync queries | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-debugging-utils](docs/rules/no-debugging-utils.md) | Disallow the use of debugging utilities like `debug` | | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | +| [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | 🔧 | +| [no-global-regexp-flag-in-query](docs/rules/no-global-regexp-flag-in-query.md) | Disallow the use of the global RegExp flag (/g) in queries | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | 🔧 | +| [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-node-access](docs/rules/no-node-access.md) | Disallow direct Node access | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-promise-in-fire-event](docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-render-in-lifecycle](docs/rules/no-render-in-lifecycle.md) | Disallow the use of `render` in testing frameworks setup functions | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-unnecessary-act](docs/rules/no-unnecessary-act.md) | Disallow wrapping Testing Library utils or empty callbacks in `act` | ![badge-marko][] ![badge-react][] | | | +| [no-wait-for-multiple-assertions](docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple `expect` calls inside `waitFor` | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-wait-for-side-effects](docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | +| [prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | 🔧 | +| [prefer-implicit-assert](docs/rules/prefer-implicit-assert.md) | Suggest using implicit assertions for getBy* & findBy* queries | | | | +| [prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [prefer-query-by-disappearance](docs/rules/prefer-query-by-disappearance.md) | Suggest using `queryBy*` queries when waiting for disappearance | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [prefer-query-matchers](docs/rules/prefer-query-matchers.md) | Ensure the configured `get*`/`query*` query is used with the corresponding matchers | | | | +| [prefer-screen-queries](docs/rules/prefer-screen-queries.md) | Suggest using `screen` while querying | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | +| [prefer-user-event](docs/rules/prefer-user-event.md) | Suggest using `userEvent` over `fireEvent` for simulating user interactions | | | | +| [render-result-naming-convention](docs/rules/render-result-naming-convention.md) | Enforce a valid naming for return value from `render` | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | | diff --git a/docs/rules/await-async-events.md b/docs/rules/await-async-events.md index 8f21ce33..2adb43a1 100644 --- a/docs/rules/await-async-events.md +++ b/docs/rules/await-async-events.md @@ -1,6 +1,6 @@ # Enforce promises from async event methods are handled (`testing-library/await-async-events`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). diff --git a/docs/rules/await-async-queries.md b/docs/rules/await-async-queries.md index 520b6968..946d87a3 100644 --- a/docs/rules/await-async-queries.md +++ b/docs/rules/await-async-queries.md @@ -1,6 +1,6 @@ # Enforce promises from async queries to be handled (`testing-library/await-async-queries`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/await-async-utils.md b/docs/rules/await-async-utils.md index b5433d83..fbc47181 100644 --- a/docs/rules/await-async-utils.md +++ b/docs/rules/await-async-utils.md @@ -1,6 +1,6 @@ # Enforce promises from async utils to be awaited properly (`testing-library/await-async-utils`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-await-sync-queries.md b/docs/rules/no-await-sync-queries.md index a4538d71..50f639b5 100644 --- a/docs/rules/no-await-sync-queries.md +++ b/docs/rules/no-await-sync-queries.md @@ -1,6 +1,6 @@ # Disallow unnecessary `await` for sync queries (`testing-library/no-await-sync-queries`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-container.md b/docs/rules/no-container.md index aab7c8ac..78372a4f 100644 --- a/docs/rules/no-container.md +++ b/docs/rules/no-container.md @@ -1,6 +1,6 @@ # Disallow the use of `container` methods (`testing-library/no-container`) -💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-debugging-utils.md b/docs/rules/no-debugging-utils.md index cb91690e..3d014d5e 100644 --- a/docs/rules/no-debugging-utils.md +++ b/docs/rules/no-debugging-utils.md @@ -1,6 +1,6 @@ # Disallow the use of debugging utilities like `debug` (`testing-library/no-debugging-utils`) -⚠️ This rule _warns_ in the following configs: `angular`, `marko`, `react`, `vue`. +⚠️ This rule _warns_ in the following configs: `angular`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-dom-import.md b/docs/rules/no-dom-import.md index f21966a2..ad6b97a4 100644 --- a/docs/rules/no-dom-import.md +++ b/docs/rules/no-dom-import.md @@ -1,6 +1,6 @@ # Disallow importing from DOM Testing Library (`testing-library/no-dom-import`) -💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `svelte`, `vue`. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). diff --git a/docs/rules/no-global-regexp-flag-in-query.md b/docs/rules/no-global-regexp-flag-in-query.md index 75e5a18a..5bca5f1c 100644 --- a/docs/rules/no-global-regexp-flag-in-query.md +++ b/docs/rules/no-global-regexp-flag-in-query.md @@ -1,6 +1,6 @@ # Disallow the use of the global RegExp flag (/g) in queries (`testing-library/no-global-regexp-flag-in-query`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). diff --git a/docs/rules/no-manual-cleanup.md b/docs/rules/no-manual-cleanup.md index 7c0b0115..69681cba 100644 --- a/docs/rules/no-manual-cleanup.md +++ b/docs/rules/no-manual-cleanup.md @@ -1,6 +1,6 @@ # Disallow the use of `cleanup` (`testing-library/no-manual-cleanup`) -💼 This rule is enabled in the following configs: `react`, `vue`. +💼 This rule is enabled in the following configs: `react`, `svelte`, `vue`. diff --git a/docs/rules/no-node-access.md b/docs/rules/no-node-access.md index 91c0727a..7290cec3 100644 --- a/docs/rules/no-node-access.md +++ b/docs/rules/no-node-access.md @@ -1,6 +1,6 @@ # Disallow direct Node access (`testing-library/no-node-access`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-promise-in-fire-event.md b/docs/rules/no-promise-in-fire-event.md index 37e3b597..e9bf9b42 100644 --- a/docs/rules/no-promise-in-fire-event.md +++ b/docs/rules/no-promise-in-fire-event.md @@ -1,6 +1,6 @@ # Disallow the use of promises passed to a `fireEvent` method (`testing-library/no-promise-in-fire-event`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-render-in-lifecycle.md b/docs/rules/no-render-in-lifecycle.md index 7c610feb..bbbea3d8 100644 --- a/docs/rules/no-render-in-lifecycle.md +++ b/docs/rules/no-render-in-lifecycle.md @@ -1,6 +1,6 @@ # Disallow the use of `render` in testing frameworks setup functions (`testing-library/no-render-in-lifecycle`) -💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-wait-for-multiple-assertions.md b/docs/rules/no-wait-for-multiple-assertions.md index ee418cf9..1154de6d 100644 --- a/docs/rules/no-wait-for-multiple-assertions.md +++ b/docs/rules/no-wait-for-multiple-assertions.md @@ -1,6 +1,6 @@ # Disallow the use of multiple `expect` calls inside `waitFor` (`testing-library/no-wait-for-multiple-assertions`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-wait-for-side-effects.md b/docs/rules/no-wait-for-side-effects.md index 475b06de..08cc31f1 100644 --- a/docs/rules/no-wait-for-side-effects.md +++ b/docs/rules/no-wait-for-side-effects.md @@ -1,6 +1,6 @@ # Disallow the use of side effects in `waitFor` (`testing-library/no-wait-for-side-effects`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/no-wait-for-snapshot.md b/docs/rules/no-wait-for-snapshot.md index e29fb7fa..71b2fd49 100644 --- a/docs/rules/no-wait-for-snapshot.md +++ b/docs/rules/no-wait-for-snapshot.md @@ -1,6 +1,6 @@ # Ensures no snapshot is generated inside of a `waitFor` call (`testing-library/no-wait-for-snapshot`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/prefer-find-by.md b/docs/rules/prefer-find-by.md index 1cc5b217..2a39b131 100644 --- a/docs/rules/prefer-find-by.md +++ b/docs/rules/prefer-find-by.md @@ -1,6 +1,6 @@ # Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements (`testing-library/prefer-find-by`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). diff --git a/docs/rules/prefer-presence-queries.md b/docs/rules/prefer-presence-queries.md index 91ab2b66..2bb3174a 100644 --- a/docs/rules/prefer-presence-queries.md +++ b/docs/rules/prefer-presence-queries.md @@ -1,6 +1,6 @@ # Ensure appropriate `get*`/`query*` queries are used with their respective matchers (`testing-library/prefer-presence-queries`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/prefer-query-by-disappearance.md b/docs/rules/prefer-query-by-disappearance.md index dcf35a20..6d20641f 100644 --- a/docs/rules/prefer-query-by-disappearance.md +++ b/docs/rules/prefer-query-by-disappearance.md @@ -1,6 +1,6 @@ # Suggest using `queryBy*` queries when waiting for disappearance (`testing-library/prefer-query-by-disappearance`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/prefer-screen-queries.md b/docs/rules/prefer-screen-queries.md index 4d4c1753..fd0d5320 100644 --- a/docs/rules/prefer-screen-queries.md +++ b/docs/rules/prefer-screen-queries.md @@ -1,6 +1,6 @@ # Suggest using `screen` while querying (`testing-library/prefer-screen-queries`) -💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `svelte`, `vue`. diff --git a/docs/rules/render-result-naming-convention.md b/docs/rules/render-result-naming-convention.md index 5d76ab2c..acadab69 100644 --- a/docs/rules/render-result-naming-convention.md +++ b/docs/rules/render-result-naming-convention.md @@ -1,6 +1,6 @@ # Enforce a valid naming for return value from `render` (`testing-library/render-result-naming-convention`) -💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `vue`. +💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `svelte`, `vue`. diff --git a/index.d.ts b/index.d.ts index 360dbbfa..88c1baad 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,12 +10,14 @@ declare const plugin: { dom: Linter.LegacyConfig; marko: Linter.LegacyConfig; react: Linter.LegacyConfig; + svelte: Linter.LegacyConfig; vue: Linter.LegacyConfig; - 'flat/angular': Linter.FlatConfig; - 'flat/dom': Linter.FlatConfig; - 'flat/marko': Linter.FlatConfig; - 'flat/react': Linter.FlatConfig; - 'flat/vue': Linter.FlatConfig; + 'flat/angular': Linter.Config; + 'flat/dom': Linter.Config; + 'flat/marko': Linter.Config; + 'flat/react': Linter.Config; + 'flat/svelte': Linter.Config; + 'flat/vue': Linter.Config; }; rules: { [key: string]: Rule.RuleModule; diff --git a/lib/configs/svelte.ts b/lib/configs/svelte.ts new file mode 100644 index 00000000..7713f9db --- /dev/null +++ b/lib/configs/svelte.ts @@ -0,0 +1,32 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING pnpm run generate:configs + +export = { + plugins: ['testing-library'], + rules: { + 'testing-library/await-async-events': [ + 'error', + { eventModule: ['fireEvent', 'userEvent'] }, + ], + 'testing-library/await-async-queries': 'error', + 'testing-library/await-async-utils': 'error', + 'testing-library/no-await-sync-queries': 'error', + 'testing-library/no-container': 'error', + 'testing-library/no-debugging-utils': 'warn', + 'testing-library/no-dom-import': ['error', 'svelte'], + 'testing-library/no-global-regexp-flag-in-query': 'error', + 'testing-library/no-manual-cleanup': 'error', + 'testing-library/no-node-access': 'error', + 'testing-library/no-promise-in-fire-event': 'error', + 'testing-library/no-render-in-lifecycle': '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', + }, +}; diff --git a/lib/rules/await-async-events.ts b/lib/rules/await-async-events.ts index 7d4d81e2..7ac69ede 100644 --- a/lib/rules/await-async-events.ts +++ b/lib/rules/await-async-events.ts @@ -35,6 +35,7 @@ export default createTestingLibraryRule({ angular: ['error', { eventModule: 'userEvent' }], react: ['error', { eventModule: 'userEvent' }], vue: ['error', { eventModule: ['fireEvent', 'userEvent'] }], + svelte: ['error', { eventModule: ['fireEvent', 'userEvent'] }], marko: ['error', { eventModule: ['fireEvent', 'userEvent'] }], }, }, diff --git a/lib/rules/await-async-queries.ts b/lib/rules/await-async-queries.ts index 6da6b0d2..a2befb2a 100644 --- a/lib/rules/await-async-queries.ts +++ b/lib/rules/await-async-queries.ts @@ -25,6 +25,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/await-async-utils.ts b/lib/rules/await-async-utils.ts index a52e96d0..74cb382d 100644 --- a/lib/rules/await-async-utils.ts +++ b/lib/rules/await-async-utils.ts @@ -27,6 +27,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/consistent-data-testid.ts b/lib/rules/consistent-data-testid.ts index f8b7ff6e..f6d32611 100644 --- a/lib/rules/consistent-data-testid.ts +++ b/lib/rules/consistent-data-testid.ts @@ -27,6 +27,7 @@ export default createTestingLibraryRule({ angular: false, react: false, vue: false, + svelte: false, marko: false, }, }, diff --git a/lib/rules/no-await-sync-events.ts b/lib/rules/no-await-sync-events.ts index 534c3340..5d563571 100644 --- a/lib/rules/no-await-sync-events.ts +++ b/lib/rules/no-await-sync-events.ts @@ -33,6 +33,7 @@ export default createTestingLibraryRule({ angular: ['error', { eventModules: DEFAULT_EVENT_MODULES }], react: ['error', { eventModules: DEFAULT_EVENT_MODULES }], vue: false, + svelte: false, marko: false, }, }, diff --git a/lib/rules/no-await-sync-queries.ts b/lib/rules/no-await-sync-queries.ts index c6f4a70c..b9c3414c 100644 --- a/lib/rules/no-await-sync-queries.ts +++ b/lib/rules/no-await-sync-queries.ts @@ -18,6 +18,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-container.ts b/lib/rules/no-container.ts index 54423db5..a3614cf9 100644 --- a/lib/rules/no-container.ts +++ b/lib/rules/no-container.ts @@ -25,6 +25,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-debugging-utils.ts b/lib/rules/no-debugging-utils.ts index cccc69d0..470c2028 100644 --- a/lib/rules/no-debugging-utils.ts +++ b/lib/rules/no-debugging-utils.ts @@ -40,6 +40,7 @@ export default createTestingLibraryRule({ angular: 'warn', react: 'warn', vue: 'warn', + svelte: 'warn', marko: 'warn', }, }, diff --git a/lib/rules/no-dom-import.ts b/lib/rules/no-dom-import.ts index b35e7203..974c34fa 100644 --- a/lib/rules/no-dom-import.ts +++ b/lib/rules/no-dom-import.ts @@ -40,6 +40,7 @@ export default createTestingLibraryRule({ angular: ['error', 'angular'], react: ['error', 'react'], vue: ['error', 'vue'], + svelte: ['error', 'svelte'], marko: ['error', 'marko'], }, }, diff --git a/lib/rules/no-global-regexp-flag-in-query.ts b/lib/rules/no-global-regexp-flag-in-query.ts index f69894d6..50293045 100644 --- a/lib/rules/no-global-regexp-flag-in-query.ts +++ b/lib/rules/no-global-regexp-flag-in-query.ts @@ -25,6 +25,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-manual-cleanup.ts b/lib/rules/no-manual-cleanup.ts index 184f23ed..5e22d307 100644 --- a/lib/rules/no-manual-cleanup.ts +++ b/lib/rules/no-manual-cleanup.ts @@ -32,6 +32,7 @@ export default createTestingLibraryRule({ angular: false, react: 'error', vue: 'error', + svelte: 'error', marko: false, }, }, diff --git a/lib/rules/no-node-access.ts b/lib/rules/no-node-access.ts index 78ffdc31..0fcd78ac 100644 --- a/lib/rules/no-node-access.ts +++ b/lib/rules/no-node-access.ts @@ -18,6 +18,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-promise-in-fire-event.ts b/lib/rules/no-promise-in-fire-event.ts index f10bfc77..a60967ec 100644 --- a/lib/rules/no-promise-in-fire-event.ts +++ b/lib/rules/no-promise-in-fire-event.ts @@ -26,6 +26,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-render-in-lifecycle.ts b/lib/rules/no-render-in-lifecycle.ts index 27771c52..c15fcd19 100644 --- a/lib/rules/no-render-in-lifecycle.ts +++ b/lib/rules/no-render-in-lifecycle.ts @@ -55,6 +55,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 3d4317b5..f80cf160 100644 --- a/lib/rules/no-unnecessary-act.ts +++ b/lib/rules/no-unnecessary-act.ts @@ -28,6 +28,7 @@ export default createTestingLibraryRule({ angular: false, react: 'error', vue: false, + svelte: false, marko: 'error', }, }, diff --git a/lib/rules/no-wait-for-multiple-assertions.ts b/lib/rules/no-wait-for-multiple-assertions.ts index df9c1f52..b4df2a73 100644 --- a/lib/rules/no-wait-for-multiple-assertions.ts +++ b/lib/rules/no-wait-for-multiple-assertions.ts @@ -22,6 +22,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-wait-for-side-effects.ts b/lib/rules/no-wait-for-side-effects.ts index a6673409..d2cf1aab 100644 --- a/lib/rules/no-wait-for-side-effects.ts +++ b/lib/rules/no-wait-for-side-effects.ts @@ -26,6 +26,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/no-wait-for-snapshot.ts b/lib/rules/no-wait-for-snapshot.ts index 4e2b84ef..c7c41386 100644 --- a/lib/rules/no-wait-for-snapshot.ts +++ b/lib/rules/no-wait-for-snapshot.ts @@ -24,6 +24,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/prefer-explicit-assert.ts b/lib/rules/prefer-explicit-assert.ts index 82cfaafa..7dc78f2c 100644 --- a/lib/rules/prefer-explicit-assert.ts +++ b/lib/rules/prefer-explicit-assert.ts @@ -75,6 +75,7 @@ export default createTestingLibraryRule({ angular: false, react: false, vue: false, + svelte: false, marko: false, }, }, diff --git a/lib/rules/prefer-find-by.ts b/lib/rules/prefer-find-by.ts index 7e48993b..1fc26ebd 100644 --- a/lib/rules/prefer-find-by.ts +++ b/lib/rules/prefer-find-by.ts @@ -57,6 +57,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/prefer-implicit-assert.ts b/lib/rules/prefer-implicit-assert.ts index 43f7682d..c1c404a0 100644 --- a/lib/rules/prefer-implicit-assert.ts +++ b/lib/rules/prefer-implicit-assert.ts @@ -70,6 +70,7 @@ export default createTestingLibraryRule({ angular: false, react: false, vue: false, + svelte: false, marko: false, }, }, diff --git a/lib/rules/prefer-presence-queries.ts b/lib/rules/prefer-presence-queries.ts index b654dd6a..a810f869 100644 --- a/lib/rules/prefer-presence-queries.ts +++ b/lib/rules/prefer-presence-queries.ts @@ -23,6 +23,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/prefer-query-by-disappearance.ts b/lib/rules/prefer-query-by-disappearance.ts index 19aa670a..d09b6f8d 100644 --- a/lib/rules/prefer-query-by-disappearance.ts +++ b/lib/rules/prefer-query-by-disappearance.ts @@ -28,6 +28,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/prefer-query-matchers.ts b/lib/rules/prefer-query-matchers.ts index 80e819e9..123a7123 100644 --- a/lib/rules/prefer-query-matchers.ts +++ b/lib/rules/prefer-query-matchers.ts @@ -25,6 +25,7 @@ export default createTestingLibraryRule({ angular: false, react: false, vue: false, + svelte: false, marko: false, }, }, diff --git a/lib/rules/prefer-screen-queries.ts b/lib/rules/prefer-screen-queries.ts index 0d49d426..4271e4b3 100644 --- a/lib/rules/prefer-screen-queries.ts +++ b/lib/rules/prefer-screen-queries.ts @@ -45,6 +45,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/rules/prefer-user-event.ts b/lib/rules/prefer-user-event.ts index daf408d1..04e8530b 100644 --- a/lib/rules/prefer-user-event.ts +++ b/lib/rules/prefer-user-event.ts @@ -76,6 +76,7 @@ export default createTestingLibraryRule({ angular: false, react: false, vue: false, + svelte: false, marko: false, }, }, diff --git a/lib/rules/render-result-naming-convention.ts b/lib/rules/render-result-naming-convention.ts index 9bce2bd8..f1c4101b 100644 --- a/lib/rules/render-result-naming-convention.ts +++ b/lib/rules/render-result-naming-convention.ts @@ -29,6 +29,7 @@ export default createTestingLibraryRule({ angular: 'error', react: 'error', vue: 'error', + svelte: 'error', marko: 'error', }, }, diff --git a/lib/utils/types.ts b/lib/utils/types.ts index 6b42fbde..7f96e80d 100644 --- a/lib/utils/types.ts +++ b/lib/utils/types.ts @@ -31,6 +31,7 @@ export const SUPPORTED_TESTING_FRAMEWORKS = [ 'angular', 'react', 'vue', + 'svelte', 'marko', ] as const; export type SupportedTestingFramework = diff --git a/tests/fake-rule.ts b/tests/fake-rule.ts index 23bf6383..335eaee5 100644 --- a/tests/fake-rule.ts +++ b/tests/fake-rule.ts @@ -31,6 +31,7 @@ export default createTestingLibraryRule({ angular: false, react: false, vue: false, + svelte: false, marko: false, }, }, diff --git a/tests/index.test.ts b/tests/index.test.ts index d6dc83eb..0695abde 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -51,11 +51,13 @@ it('should export configs that refer to actual rules', () => { 'angular', 'react', 'vue', + 'svelte', 'marko', 'flat/dom', 'flat/angular', 'flat/react', 'flat/vue', + 'flat/svelte', 'flat/marko', ]); const allConfigRules = Object.values(allConfigs)