Skip to content

Commit

Permalink
feat: add config for Svelte (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
Belco90 authored Dec 4, 2024
2 parents 496ecf6 + 26d360e commit fc118c7
Show file tree
Hide file tree
Showing 54 changed files with 149 additions and 54 deletions.
1 change: 1 addition & 0 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = {
'flat/dom',
'flat/marko',
'flat/react',
'flat/svelte',
'flat/vue',
],
postprocess: (content) =>
Expand Down
87 changes: 58 additions & 29 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/rules/await-async-events.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/await-async-queries.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/await-async-utils.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-await-sync-queries.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-container.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-debugging-utils.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-dom-import.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-global-regexp-flag-in-query.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-manual-cleanup.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-node-access.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-promise-in-fire-event.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-render-in-lifecycle.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-wait-for-multiple-assertions.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-wait-for-side-effects.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-wait-for-snapshot.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/prefer-find-by.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/prefer-presence-queries.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/prefer-query-by-disappearance.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/prefer-screen-queries.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/render-result-naming-convention.md
Original file line number Diff line number Diff line change
@@ -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`.

<!-- end auto-generated rule header -->

Expand Down
12 changes: 7 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Linter.RulesRecord>;
'flat/dom': Linter.Config<Linter.RulesRecord>;
'flat/marko': Linter.Config<Linter.RulesRecord>;
'flat/react': Linter.Config<Linter.RulesRecord>;
'flat/svelte': Linter.Config<Linter.RulesRecord>;
'flat/vue': Linter.Config<Linter.RulesRecord>;
};
rules: {
[key: string]: Rule.RuleModule;
Expand Down
32 changes: 32 additions & 0 deletions lib/configs/svelte.ts
Original file line number Diff line number Diff line change
@@ -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',
},
};
1 change: 1 addition & 0 deletions lib/rules/await-async-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: ['error', { eventModule: 'userEvent' }],
react: ['error', { eventModule: 'userEvent' }],
vue: ['error', { eventModule: ['fireEvent', 'userEvent'] }],
svelte: ['error', { eventModule: ['fireEvent', 'userEvent'] }],
marko: ['error', { eventModule: ['fireEvent', 'userEvent'] }],
},
},
Expand Down
1 change: 1 addition & 0 deletions lib/rules/await-async-queries.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',
svelte: 'error',
marko: 'error',
},
},
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 @@ -27,6 +27,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
svelte: 'error',
marko: 'error',
},
},
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 @@ -27,6 +27,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
svelte: false,
marko: false,
},
},
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 @@ -33,6 +33,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: ['error', { eventModules: DEFAULT_EVENT_MODULES }],
react: ['error', { eventModules: DEFAULT_EVENT_MODULES }],
vue: false,
svelte: false,
marko: false,
},
},
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-await-sync-queries.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',
svelte: 'error',
marko: 'error',
},
},
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',
svelte: 'error',
marko: 'error',
},
},
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 @@ -40,6 +40,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'warn',
react: 'warn',
vue: 'warn',
svelte: 'warn',
marko: 'warn',
},
},
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-dom-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: ['error', 'angular'],
react: ['error', 'react'],
vue: ['error', 'vue'],
svelte: ['error', 'svelte'],
marko: ['error', 'marko'],
},
},
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: 'error',
react: 'error',
vue: 'error',
svelte: 'error',
marko: 'error',
},
},
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 @@ -32,6 +32,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: 'error',
vue: 'error',
svelte: 'error',
marko: false,
},
},
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',
svelte: 'error',
marko: 'error',
},
},
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 @@ -26,6 +26,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
svelte: 'error',
marko: 'error',
},
},
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-render-in-lifecycle.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',
svelte: 'error',
marko: 'error',
},
},
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,
svelte: false,
marko: 'error',
},
},
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',
svelte: 'error',
marko: 'error',
},
},
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 @@ -26,6 +26,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
svelte: 'error',
marko: 'error',
},
},
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',
svelte: 'error',
marko: 'error',
},
},
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 @@ -75,6 +75,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
svelte: false,
marko: false,
},
},
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',
svelte: 'error',
marko: 'error',
},
},
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-implicit-assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
svelte: false,
marko: false,
},
},
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',
svelte: 'error',
marko: 'error',
},
},
Expand Down
Loading

0 comments on commit fc118c7

Please sign in to comment.