From d4303f5347dae7828e08e699741a276ee35dbd43 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 4 Mar 2024 09:30:14 +0900 Subject: [PATCH] fix: update svelte-eslint-parser (#696) --- .changeset/lovely-papayas-cough.md | 5 +++++ package.json | 10 +++++----- src/rules/no-unused-class-name.ts | 2 ++ src/types-for-node.ts | 2 ++ src/utils/ast-utils.ts | 4 +++- .../rules/indent/invalid/const-tag01-requirements.json | 4 ---- 6 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .changeset/lovely-papayas-cough.md delete mode 100644 tests/fixtures/rules/indent/invalid/const-tag01-requirements.json diff --git a/.changeset/lovely-papayas-cough.md b/.changeset/lovely-papayas-cough.md new file mode 100644 index 000000000..bedb4c42b --- /dev/null +++ b/.changeset/lovely-papayas-cough.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-svelte": patch +--- + +fix: update svelte-eslint-parser diff --git a/package.json b/package.json index c72099429..6d855e4f1 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "postcss-safe-parser": "^6.0.0", "postcss-selector-parser": "^6.0.15", "semver": "^7.6.0", - "svelte-eslint-parser": ">=0.34.0-next.10 <1.0.0" + "svelte-eslint-parser": ">=0.34.0-next.11 <1.0.0" }, "devDependencies": { "@1stg/browserslist-config": "^2.0.0", @@ -90,7 +90,7 @@ "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.1", "@changesets/get-release-plan": "^4.0.0", - "@fontsource/fira-mono": "^5.0.8", + "@fontsource/fira-mono": "^5.0.12", "@ota-meshi/eslint-plugin": "^0.15.2", "@sindresorhus/slugify": "^2.2.1", "@sveltejs/adapter-static": "^3.0.1", @@ -110,7 +110,7 @@ "@types/markdown-it-container": "^2.0.9", "@types/markdown-it-emoji": "^2.0.4", "@types/mocha": "^10.0.6", - "@types/node": "^20.11.22", + "@types/node": "^20.11.24", "@types/postcss-safe-parser": "^5.0.4", "@types/prismjs": "^1.26.3", "@types/semver": "^7.5.8", @@ -146,7 +146,7 @@ "estree-walker": "^3.0.3", "less": "^4.2.0", "locate-character": "^3.0.0", - "magic-string": "^0.30.7", + "magic-string": "^0.30.8", "markdown-it-anchor": "^8.6.7", "markdown-it-container": "^4.0.0", "markdown-it-emoji": "^3.0.0", @@ -166,7 +166,7 @@ "stylelint": "^16.2.1", "stylelint-config-standard": "^36.0.0", "stylus": "^0.62.0", - "svelte": "^5.0.0-next.69", + "svelte": "^5.0.0-next.70", "svelte-adapter-ghpages": "0.2.2", "svelte-i18n": "^4.0.0", "tslib": "^2.6.2", diff --git a/src/rules/no-unused-class-name.ts b/src/rules/no-unused-class-name.ts index 40a23b6e7..57f795725 100644 --- a/src/rules/no-unused-class-name.ts +++ b/src/rules/no-unused-class-name.ts @@ -3,6 +3,7 @@ import type { SourceLocation, SvelteAttribute, SvelteDirective, + SvelteGenericsDirective, SvelteShorthandAttribute, SvelteSpecialDirective, SvelteSpreadAttribute, @@ -85,6 +86,7 @@ function findClassesInAttribute( | SvelteDirective | SvelteStyleDirective | SvelteSpecialDirective + | SvelteGenericsDirective ): string[] { if (attribute.type === 'SvelteAttribute' && attribute.key.name === 'class') { return attribute.value.flatMap((value) => diff --git a/src/types-for-node.ts b/src/types-for-node.ts index ec2d5ff8a..866ea6dab 100644 --- a/src/types-for-node.ts +++ b/src/types-for-node.ts @@ -237,6 +237,7 @@ export type ASTNodeListener = { SvelteDirective?: (node: AST.SvelteDirective & ASTNodeWithParent) => void; SvelteStyleDirective?: (node: AST.SvelteStyleDirective & ASTNodeWithParent) => void; SvelteSpecialDirective?: (node: AST.SvelteSpecialDirective & ASTNodeWithParent) => void; + SvelteGenericsDirective?: (node: AST.SvelteGenericsDirective & ASTNodeWithParent) => void; SvelteDirectiveKey?: (node: AST.SvelteDirectiveKey & ASTNodeWithParent) => void; SvelteSpecialDirectiveKey?: (node: AST.SvelteSpecialDirectiveKey & ASTNodeWithParent) => void; SvelteText?: (node: AST.SvelteText & ASTNodeWithParent) => void; @@ -457,6 +458,7 @@ export type SvelteNodeListener = { SvelteDirective?: (node: AST.SvelteDirective & ASTNodeWithParent) => void; SvelteStyleDirective?: (node: AST.SvelteStyleDirective & ASTNodeWithParent) => void; SvelteSpecialDirective?: (node: AST.SvelteSpecialDirective & ASTNodeWithParent) => void; + SvelteGenericsDirective?: (node: AST.SvelteGenericsDirective & ASTNodeWithParent) => void; SvelteDirectiveKey?: (node: AST.SvelteDirectiveKey & ASTNodeWithParent) => void; SvelteSpecialDirectiveKey?: (node: AST.SvelteSpecialDirectiveKey & ASTNodeWithParent) => void; SvelteText?: (node: AST.SvelteText & ASTNodeWithParent) => void; diff --git a/src/utils/ast-utils.ts b/src/utils/ast-utils.ts index c347bb2c9..3e0cd7c82 100644 --- a/src/utils/ast-utils.ts +++ b/src/utils/ast-utils.ts @@ -462,12 +462,14 @@ export function getAttributeKeyText( | SvAST.SvelteShorthandAttribute | SvAST.SvelteStyleDirective | SvAST.SvelteDirective - | SvAST.SvelteSpecialDirective, + | SvAST.SvelteSpecialDirective + | SvAST.SvelteGenericsDirective, context: RuleContext ): string { switch (node.type) { case 'SvelteAttribute': case 'SvelteShorthandAttribute': + case 'SvelteGenericsDirective': return node.key.name; case 'SvelteStyleDirective': return `style:${node.key.name.name}`; diff --git a/tests/fixtures/rules/indent/invalid/const-tag01-requirements.json b/tests/fixtures/rules/indent/invalid/const-tag01-requirements.json deleted file mode 100644 index 5c890e854..000000000 --- a/tests/fixtures/rules/indent/invalid/const-tag01-requirements.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "FIXME": "Bug in Svelte v5-next.68?", - "svelte": "^4 || ^3" -}