Skip to content

Commit 22b8778

Browse files
committed
feat(sort-attributes): support {@Attach}
1 parent 0265218 commit 22b8778

File tree

7 files changed

+53
-4
lines changed

7 files changed

+53
-4
lines changed

docs-svelte-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"sass": "^1.81.0",
5757
"source-map-js": "^1.2.1",
5858
"stylus": "^0.64.0",
59-
"svelte": "^5.2.10",
59+
"svelte": "^5.30.1",
6060
"svelte-adapter-ghpages": "0.2.2",
6161
"twoslash-eslint": "^0.3.0",
6262
"twoslash-protocol": "^0.3.0",

packages/eslint-plugin-svelte/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"postcss-load-config": "^3.1.4",
6565
"postcss-safe-parser": "^7.0.0",
6666
"semver": "^7.6.3",
67-
"svelte-eslint-parser": "^1.1.1"
67+
"svelte-eslint-parser": "^1.2.0"
6868
},
6969
"devDependencies": {
7070
"@babel/core": "^7.26.0",
@@ -95,7 +95,7 @@
9595
"sass": "^1.81.0",
9696
"source-map-js": "^1.2.1",
9797
"stylus": "^0.64.0",
98-
"svelte": "^5.2.9",
98+
"svelte": "^5.30.1",
9999
"svelte-i18n": "^4.0.1",
100100
"tsx": "^4.19.2",
101101
"type-coverage": "^2.29.7",

packages/eslint-plugin-svelte/src/utils/ast-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ export function getAttributeKeyText(
462462
| SvAST.SvelteStyleDirective
463463
| SvAST.SvelteDirective
464464
| SvAST.SvelteSpecialDirective
465-
| SvAST.SvelteGenericsDirective,
465+
| SvAST.SvelteGenericsDirective
466+
| SvAST.SvelteAttachTag,
466467
context: RuleContext
467468
): string {
468469
switch (node.type) {
@@ -480,6 +481,8 @@ export function getAttributeKeyText(
480481
node.key.modifiers.length ? `|${node.key.modifiers.join('|')}` : ''
481482
}`;
482483
}
484+
case 'SvelteAttachTag':
485+
return '@attach';
483486
default:
484487
throw new Error(
485488
`Unknown node type: ${
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Attribute '@attach' should go before 'foo'.
2+
line: 14
3+
column: 10
4+
suggestions: null
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import type { Attachment } from 'svelte/attachments';
3+
4+
5+
const myAttachment: Attachment = (element) => {
6+
console.log(element.nodeName); // 'DIV'
7+
8+
return () => {
9+
console.log('cleaning up');
10+
};
11+
};
12+
</script>
13+
14+
<div foo {@attach myAttachment}>...</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import type { Attachment } from 'svelte/attachments';
3+
4+
5+
const myAttachment: Attachment = (element) => {
6+
console.log(element.nodeName); // 'DIV'
7+
8+
return () => {
9+
console.log('cleaning up');
10+
};
11+
};
12+
</script>
13+
14+
<div {@attach myAttachment} foo>...</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import type { Attachment } from 'svelte/attachments';
3+
4+
5+
const myAttachment: Attachment = (element) => {
6+
console.log(element.nodeName); // 'DIV'
7+
8+
return () => {
9+
console.log('cleaning up');
10+
};
11+
};
12+
</script>
13+
14+
<div {@attach myAttachment}>...</div>

0 commit comments

Comments
 (0)