Skip to content

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

Closed
@ryoppippi

Description

@ryoppippi

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/eslint-plugin-svelte@3.6.0_eslint@9.26.0_jiti@1.21.7__sve
lte@5.30.1/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/eslint-plugin-svelte@3.6.0_eslint@9.26.0_jiti@1.21.7__svelte@5.30.
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/eslint-plugin-svelte@3.6.0_eslint@9.26.0_jiti@1.21.7__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/eslint@9.26.0_jiti@1.21.7/node_modules/eslint/lib/linter/linter.js:
1310:33)
    at /Users/ryoppippi/ghq/github.com/vim-jp-radio/LP/node_modules/.pnpm/eslint@9.26.0_jiti@1.21.7/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/eslint@9.26.0_jiti@1.21.7/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/eslint@9.26.0_jiti@1.21.7/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/eslint@9.26.0_jiti@1.21.7/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/eslint@9.26.0_jiti@1.21.7/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions