Skip to content

Commit 9b76b46

Browse files
authored
fix: check property key instead of value in valid-prop-names-in-kit-pages rule (#1126)
1 parent 00e9b53 commit 9b76b46

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed

.changeset/gentle-guests-cross.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': patch
3+
---
4+
5+
fix: check property key instead of value in `valid-prop-names-in-kit-pages` rule

packages/eslint-plugin-svelte/src/rules/valid-prop-names-in-kit-pages.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ function checkProp(
1616
for (const p of node.id.properties) {
1717
if (
1818
p.type === 'Property' &&
19-
p.value.type === 'Identifier' &&
20-
!expectedPropNames.includes(p.value.name)
19+
p.key.type === 'Identifier' &&
20+
!expectedPropNames.includes(p.key.name)
2121
) {
2222
context.report({
23-
node: p.value,
24-
loc: p.value.loc,
23+
node: p.key,
24+
loc: p.key.loc,
2525
messageId: 'unexpected'
2626
});
2727
}

packages/eslint-plugin-svelte/tests/fixtures/rules/valid-prop-names-in-kit-pages/invalid/errors.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,3 @@
1414
line: 4
1515
column: 20
1616
suggestions: null
17-
- message: disallow props other than data or errors in SvelteKit page components.
18-
line: 5
19-
column: 21
20-
suggestions: null
21-
- message: disallow props other than data or errors in SvelteKit page components.
22-
line: 5
23-
column: 36
24-
suggestions: null

packages/eslint-plugin-svelte/tests/fixtures/rules/valid-prop-names-in-kit-pages/invalid/svelte-config-from-parser-options/errors.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,3 @@
1414
line: 4
1515
column: 20
1616
suggestions: null
17-
- message: disallow props other than data or errors in SvelteKit page components.
18-
line: 5
19-
column: 21
20-
suggestions: null
21-
- message: disallow props other than data or errors in SvelteKit page components.
22-
line: 5
23-
column: 36
24-
suggestions: null

packages/eslint-plugin-svelte/tests/fixtures/rules/valid-prop-names-in-kit-pages/invalid/svelte-config/errors.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,3 @@
1414
line: 4
1515
column: 20
1616
suggestions: null
17-
- message: disallow props other than data or errors in SvelteKit page components.
18-
line: 5
19-
column: 21
20-
suggestions: null
21-
- message: disallow props other than data or errors in SvelteKit page components.
22-
line: 5
23-
column: 36
24-
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
let { data: pageData }: { data: PageData } = $props();
3+
</script>
4+
5+
{pageData}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"languageOptions": {
3+
"parserOptions": {
4+
"svelteConfig": {
5+
"kit": {
6+
"files": {
7+
"routes": "tests/fixtures/rules/valid-prop-names-in-kit-pages/invalid/svelte5"
8+
}
9+
}
10+
}
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}

0 commit comments

Comments
 (0)