From f16729f55877b1768ec8d240fd8e416f141781ce Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Wed, 22 Jan 2025 10:40:39 +0900 Subject: [PATCH] chore: run `require-event-dispatcher-types` rule on Svelte 3/4 only (#1035) --- .changeset/nine-walls-hammer.md | 5 +++++ .../src/rules/require-event-dispatcher-types.ts | 7 ++++++- .../invalid/_requirements.json | 3 +++ .../valid/_requirements.json | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/nine-walls-hammer.md create mode 100644 packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/invalid/_requirements.json create mode 100644 packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/valid/_requirements.json diff --git a/.changeset/nine-walls-hammer.md b/.changeset/nine-walls-hammer.md new file mode 100644 index 000000000..9f4572744 --- /dev/null +++ b/.changeset/nine-walls-hammer.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-svelte': patch +--- + +chore: run `require-event-dispatcher-types` rule on Svelte 3/4 only diff --git a/packages/eslint-plugin-svelte/src/rules/require-event-dispatcher-types.ts b/packages/eslint-plugin-svelte/src/rules/require-event-dispatcher-types.ts index 1217a9e2b..f40c6b928 100644 --- a/packages/eslint-plugin-svelte/src/rules/require-event-dispatcher-types.ts +++ b/packages/eslint-plugin-svelte/src/rules/require-event-dispatcher-types.ts @@ -15,7 +15,12 @@ export default createRule('require-event-dispatcher-types', { messages: { missingTypeParameter: `Type parameters missing for the \`createEventDispatcher\` function call.` }, - type: 'suggestion' + type: 'suggestion', + conditions: [ + { + svelteVersions: ['3/4'] + } + ] }, create(context) { let isTs = false; diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/invalid/_requirements.json b/packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/invalid/_requirements.json new file mode 100644 index 000000000..b650cc296 --- /dev/null +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/invalid/_requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": "^3.0.0 || ^4.0.0" +} diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/valid/_requirements.json b/packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/valid/_requirements.json new file mode 100644 index 000000000..b650cc296 --- /dev/null +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/require-event-dispatcher-types/valid/_requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": "^3.0.0 || ^4.0.0" +}