Skip to content

attachTag is not working with svelte/sort-attributes rule #1220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
ryoppippi opened this issue May 15, 2025 · 0 comments · Fixed by #1221
Closed
2 tasks done

attachTag is not working with svelte/sort-attributes rule #1220

ryoppippi opened this issue May 15, 2025 · 0 comments · Fixed by #1221

Comments

@ryoppippi
Copy link

ryoppippi commented May 15, 2025

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.26.0

What version of eslint-plugin-svelte are you using?

3.6.0

What did you do?

<script lang="ts">
	import type { Attachment } from 'svelte/attachments';


	const myAttachment: Attachment = (element) => {
		console.log(element.nodeName); // 'DIV'

		return () => {
			console.log('cleaning up');
		};
	};
</script>

<div {@attach myAttachment}>...</div>

What did you expect to happen?

successfully linted

What actually happened?


Oops! Something went wrong! :(

ESLint: 9.26.0

Error: Unknown node type: SvelteAttachTag
Occurred while linting /Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/src/lib/Background/Background.svelte:53
Rule: "svelte/sort-attributes"
    at getAttributeKeyText (file:///Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected][email protected]__sve
[email protected]/node_modules/eslint-plugin-svelte/lib/utils/ast-utils.js:335:19)
    at getKeyText (file:///Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected][email protected][email protected].
1/node_modules/eslint-plugin-svelte/lib/rules/sort-attributes.js:202:28)
    at SvelteStartTag (file:///Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected][email protected]__svelte@5
.30.1/node_modules/eslint-plugin-svelte/lib/rules/sort-attributes.js:268:33)
    at ruleErrorHandler (/Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:
1310:33)
    at /Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/safe-emitter.js:45:46
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/safe-emitter.js
:45:26)
    at NodeEventGenerator.applySelector (/Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/l
inter/node-event-generator.js:171:17)
    at NodeEventGenerator.applySelectors (/Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/
linter/node-event-generator.js:227:10)
    at NodeEventGenerator.enterNode (/Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linte
r/node-event-generator.js:241:8)

Link to GitHub Repo with Minimal Reproducible Example

install the following eslint plugins

		"eslint": "^9.26.0",
		"eslint-plugin-format": "^0.1.2",
		"eslint-plugin-svelte": "^3.6.0",
		"svelte": "^5.30.1",
		"svelte-eslint-parser": "^1.2.0",

Additional comments

I'll create a reproducions later if we need it

Related to #1219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant