Skip to content

Commit 157ee1f

Browse files
authored
chore: update svelte-eslint-parser to v1.0.0-next.4 (#956)
1 parent 9568782 commit 157ee1f

16 files changed

+96
-46
lines changed

.changeset/hungry-grapes-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': patch
3+
---
4+
5+
chore: update `svelte-eslint-parser` to v1.0.0-next.4

packages/eslint-plugin-svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"postcss-safe-parser": "^6.0.0",
6767
"postcss-selector-parser": "^7.0.0",
6868
"semver": "^7.6.3",
69-
"svelte-eslint-parser": "^1.0.0-next.3"
69+
"svelte-eslint-parser": "^1.0.0-next.4"
7070
},
7171
"devDependencies": {
7272
"@babel/core": "^7.26.0",

packages/eslint-plugin-svelte/src/rules/indent-helpers/svelte.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ export function defineVisitor(context: IndentContext): NodeListener {
289289
const closeOpenTagToken = sourceCode.getTokenAfter(key.lastToken);
290290
offsets.setOffsetToken(closeOpenTagToken, 0, openToken);
291291
} else {
292-
const closeOpenTagToken = sourceCode.getTokenAfter(node.index || node.context);
292+
const closeOpenTagToken = sourceCode.getTokenAfter(
293+
node.index || node.context || node.expression
294+
);
293295
offsets.setOffsetToken(closeOpenTagToken, 0, openToken);
294296
}
295297

packages/eslint-plugin-svelte/src/rules/mustache-spacing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export default createRule('mustache-spacing', {
272272
SvelteEachBlock(node: AST.SvelteEachBlock) {
273273
const openBlockOpeningToken = sourceCode.getFirstToken(node);
274274
const openBlockClosingToken = sourceCode.getTokenAfter(
275-
node.key || node.index || node.context,
275+
node.key || node.index || node.context || node.expression,
276276
{
277277
includeComments: false,
278278
filter: isClosingBraceToken

packages/eslint-plugin-svelte/src/rules/no-immutable-reactive-statements.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ export default createRule('no-immutable-reactive-statements', {
135135
return parent.kind === 'Binding' && parent.expression === expr;
136136
}
137137
if (parent.type === 'SvelteEachBlock') {
138-
return parent.expression === expr && hasWriteReference(parent.context);
138+
return (
139+
parent.context !== null && parent.expression === expr && hasWriteReference(parent.context)
140+
);
139141
}
140142

141143
return false;

packages/eslint-plugin-svelte/src/rules/valid-each-key.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ export default createRule('valid-each-key', {
2727
if (
2828
!variable.defs.some(
2929
(def) =>
30-
(node.context.range[0] <= def.name.range[0] &&
30+
(node.context &&
31+
node.context.range[0] <= def.name.range[0] &&
3132
def.name.range[1] <= node.context.range[1]) ||
3233
(node.index &&
3334
node.index.range[0] <= def.name.range[0] &&
34-
def.name.range[1] <= node.index.range[1])
35+
def.name.range[1] <= node.index.range[1]) ||
36+
(node.expression &&
37+
node.expression.range[0] <= def.name.range[0] &&
38+
def.name.range[1] <= node.expression.range[1])
3539
)
3640
) {
3741
// It's not an iteration variable.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
- message: '`<img>` element should have an alt attribute(a11y_missing_attribute)'
1+
- message: |-
2+
`<img>` element should have an alt attribute
3+
https://svelte.dev/e/a11y_missing_attribute(a11y_missing_attribute)
24
line: 5
35
column: 1
46
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
- message: noninteractive element cannot have nonnegative tabIndex
2-
value(a11y_no_noninteractive_tabindex)
1+
- message: |-
2+
noninteractive element cannot have nonnegative tabIndex value
3+
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
34
line: 6
45
column: 3
56
suggestions: null
6-
- message: A form label must be associated with a
7-
control(a11y_label_has_associated_control)
7+
- message: |-
8+
A form label must be associated with a control
9+
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
810
line: 6
911
column: 3
1012
suggestions: null
11-
- message: noninteractive element cannot have nonnegative tabIndex
12-
value(a11y_no_noninteractive_tabindex)
13+
- message: |-
14+
noninteractive element cannot have nonnegative tabIndex value
15+
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
1316
line: 7
1417
column: 3
1518
suggestions: null

packages/eslint-plugin-svelte/tests/fixtures/rules/valid-compile/invalid/invalid-svelte-ignore01-svelte4-errors.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
line: 6
44
column: 3
55
suggestions: null
6-
- message: 'A11y: A form label must be associated with a
7-
control.(a11y-label-has-associated-control)'
6+
- message: 'A11y: A form label must be associated with a control.(a11y-label-has-associated-control)'
87
line: 6
98
column: 3
109
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
- message: noninteractive element cannot have nonnegative tabIndex
2-
value(a11y_no_noninteractive_tabindex)
1+
- message: |-
2+
noninteractive element cannot have nonnegative tabIndex value
3+
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
34
line: 6
45
column: 3
56
suggestions: null
6-
- message: A form label must be associated with a
7-
control(a11y_label_has_associated_control)
7+
- message: |-
8+
A form label must be associated with a control
9+
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
810
line: 6
911
column: 3
1012
suggestions: null
11-
- message: noninteractive element cannot have nonnegative tabIndex
12-
value(a11y_no_noninteractive_tabindex)
13+
- message: |-
14+
noninteractive element cannot have nonnegative tabIndex value
15+
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
1316
line: 7
1417
column: 3
1518
suggestions: null

0 commit comments

Comments
 (0)