Skip to content

Commit

Permalink
chore: update svelte-eslint-parser to v1.0.0-next.4 (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
baseballyama authored Dec 14, 2024
1 parent 9568782 commit 157ee1f
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 46 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-grapes-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-svelte': patch
---

chore: update `svelte-eslint-parser` to v1.0.0-next.4
2 changes: 1 addition & 1 deletion packages/eslint-plugin-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"postcss-safe-parser": "^6.0.0",
"postcss-selector-parser": "^7.0.0",
"semver": "^7.6.3",
"svelte-eslint-parser": "^1.0.0-next.3"
"svelte-eslint-parser": "^1.0.0-next.4"
},
"devDependencies": {
"@babel/core": "^7.26.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ export function defineVisitor(context: IndentContext): NodeListener {
const closeOpenTagToken = sourceCode.getTokenAfter(key.lastToken);
offsets.setOffsetToken(closeOpenTagToken, 0, openToken);
} else {
const closeOpenTagToken = sourceCode.getTokenAfter(node.index || node.context);
const closeOpenTagToken = sourceCode.getTokenAfter(
node.index || node.context || node.expression
);
offsets.setOffsetToken(closeOpenTagToken, 0, openToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default createRule('mustache-spacing', {
SvelteEachBlock(node: AST.SvelteEachBlock) {
const openBlockOpeningToken = sourceCode.getFirstToken(node);
const openBlockClosingToken = sourceCode.getTokenAfter(
node.key || node.index || node.context,
node.key || node.index || node.context || node.expression,
{
includeComments: false,
filter: isClosingBraceToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export default createRule('no-immutable-reactive-statements', {
return parent.kind === 'Binding' && parent.expression === expr;
}
if (parent.type === 'SvelteEachBlock') {
return parent.expression === expr && hasWriteReference(parent.context);
return (
parent.context !== null && parent.expression === expr && hasWriteReference(parent.context)
);
}

return false;
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint-plugin-svelte/src/rules/valid-each-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ export default createRule('valid-each-key', {
if (
!variable.defs.some(
(def) =>
(node.context.range[0] <= def.name.range[0] &&
(node.context &&
node.context.range[0] <= def.name.range[0] &&
def.name.range[1] <= node.context.range[1]) ||
(node.index &&
node.index.range[0] <= def.name.range[0] &&
def.name.range[1] <= node.index.range[1])
def.name.range[1] <= node.index.range[1]) ||
(node.expression &&
node.expression.range[0] <= def.name.range[0] &&
def.name.range[1] <= node.expression.range[1])
)
) {
// It's not an iteration variable.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- message: '`<img>` element should have an alt attribute(a11y_missing_attribute)'
- message: |-
`<img>` element should have an alt attribute
https://svelte.dev/e/a11y_missing_attribute(a11y_missing_attribute)
line: 5
column: 1
suggestions: null
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 6
column: 3
suggestions: null
- message: A form label must be associated with a
control(a11y_label_has_associated_control)
- message: |-
A form label must be associated with a control
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
line: 6
column: 3
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 7
column: 3
suggestions: null
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
line: 6
column: 3
suggestions: null
- message: 'A11y: A form label must be associated with a
control.(a11y-label-has-associated-control)'
- message: 'A11y: A form label must be associated with a control.(a11y-label-has-associated-control)'
line: 6
column: 3
suggestions: null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 6
column: 3
suggestions: null
- message: A form label must be associated with a
control(a11y_label_has_associated_control)
- message: |-
A form label must be associated with a control
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
line: 6
column: 3
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 7
column: 3
suggestions: null
Original file line number Diff line number Diff line change
@@ -1,53 +1,66 @@
- message: Empty block(block_empty)
- message: |-
Empty block
https://svelte.dev/e/block_empty(block_empty)
line: 2
column: 30
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 5
column: 3
suggestions: null
- message: A form label must be associated with a
control(a11y_label_has_associated_control)
- message: |-
A form label must be associated with a control
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
line: 5
column: 3
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 6
column: 3
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 9
column: 3
suggestions: null
- message: A form label must be associated with a
control(a11y_label_has_associated_control)
- message: |-
A form label must be associated with a control
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
line: 9
column: 3
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 10
column: 3
suggestions: null
- message: Empty block(block_empty)
- message: |-
Empty block
https://svelte.dev/e/block_empty(block_empty)
line: 14
column: 30
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 17
column: 3
suggestions: null
- message: A form label must be associated with a
control(a11y_label_has_associated_control)
- message: |-
A form label must be associated with a control
https://svelte.dev/e/a11y_label_has_associated_control(a11y_label_has_associated_control)
line: 17
column: 3
suggestions: null
- message: noninteractive element cannot have nonnegative tabIndex
value(a11y_no_noninteractive_tabindex)
- message: |-
noninteractive element cannot have nonnegative tabIndex value
https://svelte.dev/e/a11y_no_noninteractive_tabindex(a11y_no_noninteractive_tabindex)
line: 18
column: 3
suggestions: null
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
- message: '`<img>` element should have an alt attribute(foo)'
- message: |-
`<img>` element should have an alt attribute
https://svelte.dev/e/a11y_missing_attribute(foo)
line: 5
column: 1
suggestions: null
- message: Avoid using autofocus(foo)
- message: |-
Avoid using autofocus
https://svelte.dev/e/a11y_autofocus(foo)
line: 5
column: 12
suggestions: null
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- message: Avoid using autofocus(a11y_autofocus)
- message: |-
Avoid using autofocus
https://svelte.dev/e/a11y_autofocus(a11y_autofocus)
line: 5
column: 12
suggestions: null
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- message: The $ prefix is reserved, and cannot be used for variables and
imports(dollar_prefix_invalid)
- message: |-
The $ prefix is reserved, and cannot be used for variables and imports
https://svelte.dev/e/dollar_prefix_invalid(dollar_prefix_invalid)
line: 2
column: 8
suggestions: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="chess-board">
{#each { length: 8 }, rank}
{#each { length: 8 }}
{rank}
{/each}
{/each}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"svelte": "^5.0.0"
}

0 comments on commit 157ee1f

Please sign in to comment.