Skip to content

Commit 60e784e

Browse files
authored
chore: fix tests to follow latest Svelte 5 (#751)
I just added Node 22 but CI does not pass in #750 sveltejs/svelte#11327 changes warning messages, so I mainly copied exist tests and optimized for Svelte 5.
1 parent ade400a commit 60e784e

File tree

137 files changed

+739
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+739
-105
lines changed

docs-svelte-kit/src/lib/components/ESLintPlayground.svelte

+9-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@
190190
<ol>
191191
{#each messages as msg, i (`${msg.line}:${msg.column}:${msg.ruleId}@${i}`)}
192192
<li class="message">
193-
<!-- svelte-ignore a11y-invalid-attribute -->
194-
<a href="#" on:click={(evt) => onClickMessage(evt, msg)} class="message-link"
195-
>[{msg.line}:{msg.column}]</a
196-
>:
193+
<button on:click={(evt) => onClickMessage(evt, msg)} class="message-link">
194+
[{msg.line}:{msg.column}]
195+
</button>:
197196
{msg.message}
198197
<a
199198
class="rule-link {getRule(msg.ruleId)?.classes}"
@@ -268,6 +267,12 @@
268267
color: #8080f2;
269268
}
270269
.message-link {
270+
background-color: transparent;
271+
border: none;
272+
cursor: pointer;
273+
outline: none;
274+
padding: 0;
275+
appearance: none;
271276
color: #40b3ff;
272277
}
273278
</style>

docs-svelte-kit/src/routes/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<SideMenu {sidebarOpen} hiddenMenu={frontmatter.hiddenMenu} />
3535

36-
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
36+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
3737
<main
3838
class:hidden-menu={frontmatter.hiddenMenu}
3939
on:click={sidebarOpen ? resetSidebarOpen : null}

eslint.config.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ const config = [
128128
},
129129
rules: {
130130
'n/file-extension-in-import': 'off',
131-
'n/no-unsupported-features/es-syntax': 'off'
131+
'n/no-unsupported-features/es-syntax': 'off',
132+
'n/no-unsupported-features/es-builtins': 'off'
132133
}
133134
},
134135
{
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
1+
<!-- svelte-ignore a11y_autofocus a11y_missing_attribute -->
22
<img src="foo" alt="Foo" />
33

4-
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
4+
<!-- svelte-ignore a11y_autofocus a11y_missing_attribute -->
55
<img src="foo" alt="Foo" autofocus />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
- message: svelte-ignore comment is used, but not warned
2+
line: 1
3+
column: 20
4+
suggestions: null
5+
- message: svelte-ignore comment is used, but not warned
6+
line: 1
7+
column: 35
8+
suggestions: null
9+
- message: svelte-ignore comment is used, but not warned
10+
line: 4
11+
column: 35
12+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
2+
<img src="foo" alt="Foo" />
3+
4+
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
5+
<img src="foo" alt="Foo" autofocus />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}

tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore01-input.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div>
22
{#if true}
33
A
4-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
4+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
55
{:else}
66
<label tabindex="0">Click</label>
77
<ul tabindex="0"></ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- message: svelte-ignore comment is used, but not warned
2+
line: 4
3+
column: 22
4+
suggestions: null
5+
- message: svelte-ignore comment is used, but not warned
6+
line: 4
7+
column: 56
8+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div>
2+
{#if true}
3+
A
4+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
5+
{:else}
6+
<label tabindex="0">Click</label>
7+
<ul tabindex="0"></ul>
8+
{/if}
9+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}

tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore02-input.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div>
22
{#each [] as e}
33
A
4-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
4+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
55
{:else}
66
<label tabindex="0">Click</label>
77
<ul tabindex="0"></ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- message: svelte-ignore comment is used, but not warned
2+
line: 4
3+
column: 22
4+
suggestions: null
5+
- message: svelte-ignore comment is used, but not warned
6+
line: 4
7+
column: 56
8+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div>
2+
{#each [] as e}
3+
A
4+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
5+
{:else}
6+
<label tabindex="0">Click</label>
7+
<ul tabindex="0"></ul>
8+
{/each}
9+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}

tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore03-input.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<div>
22
{#await Promise.resolve(42)}
3-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
3+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
44
{:then name}
55
<label tabindex="0">Click</label>
66
<ul tabindex="0"></ul>
7-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
7+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
88
{:catch name}
99
<label tabindex="0">Click</label>
1010
<ul tabindex="0"></ul>
1111
{/await}
1212
</div>
1313
<div>
1414
{#await Promise.resolve(42)}
15-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
15+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
1616
{:then name}
1717
<label tabindex="0">Click</label>
1818
<ul tabindex="0"></ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- message: svelte-ignore comment is used, but not warned
2+
line: 3
3+
column: 22
4+
suggestions: null
5+
- message: svelte-ignore comment is used, but not warned
6+
line: 3
7+
column: 56
8+
suggestions: null
9+
- message: svelte-ignore comment is used, but not warned
10+
line: 7
11+
column: 22
12+
suggestions: null
13+
- message: svelte-ignore comment is used, but not warned
14+
line: 7
15+
column: 56
16+
suggestions: null
17+
- message: svelte-ignore comment is used, but not warned
18+
line: 15
19+
column: 22
20+
suggestions: null
21+
- message: svelte-ignore comment is used, but not warned
22+
line: 15
23+
column: 56
24+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div>
2+
{#await Promise.resolve(42)}
3+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
4+
{:then name}
5+
<label tabindex="0">Click</label>
6+
<ul tabindex="0"></ul>
7+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
8+
{:catch name}
9+
<label tabindex="0">Click</label>
10+
<ul tabindex="0"></ul>
11+
{/await}
12+
</div>
13+
<div>
14+
{#await Promise.resolve(42)}
15+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
16+
{:then name}
17+
<label tabindex="0">Click</label>
18+
<ul tabindex="0"></ul>
19+
{/await}
20+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}

tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-errors.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
- message: svelte-ignore comment is used, but not warned
2+
line: 4
3+
column: 19
4+
suggestions: null
15
- message: svelte-ignore comment is used, but not warned
26
line: 7
37
column: 20

tests/fixtures/rules/no-unused-svelte-ignore/invalid/transform-test-input.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
</script>
33

44
<!-- ✓ GOOD -->
5-
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
5+
<!-- svelte-ignore a11y_autofocus a11y_missing_attribute -->
66
<img src="https://example.com/img.png" autofocus />
77

88
<!-- ✗ BAD -->
9-
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
9+
<!-- svelte-ignore a11y_autofocus a11y_missing_attribute -->
1010
<img src="https://example.com/img.png" alt="Foo" />
1111

1212
<div class="foo">
1313
<div class="bar" />
1414
</div>
1515

16-
<!-- svelte-ignore css-unused-selector -->
16+
<!-- svelte-ignore css_unused_selector -->
1717
<style lang="postcss">
1818
.foo {
1919
height: 20px;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
- message: svelte-ignore comment is used, but not warned
2+
line: 9
3+
column: 20
4+
suggestions: null
5+
- message: svelte-ignore comment is used, but not warned
6+
line: 9
7+
column: 35
8+
suggestions: null
9+
- message: svelte-ignore comment is used, but not warned
10+
line: 16
11+
column: 20
12+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script>
2+
</script>
3+
4+
<!-- ✓ GOOD -->
5+
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
6+
<img src="https://example.com/img.png" autofocus />
7+
8+
<!-- ✗ BAD -->
9+
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
10+
<img src="https://example.com/img.png" alt="Foo" />
11+
12+
<div class="foo">
13+
<div class="bar" />
14+
</div>
15+
16+
<!-- svelte-ignore css-unused-selector -->
17+
<style lang="postcss">
18+
.foo {
19+
height: 20px;
20+
width: 20px;
21+
& .bar {
22+
height: 10px;
23+
width: 10px;
24+
}
25+
}
26+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
1+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
22
<span tabindex="0">
33
<span class="element"></span>
44
</span>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
2+
<span tabindex="0">
3+
<span class="element"></span>
4+
</span>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
1+
<!-- svelte-ignore a11y_autofocus a11y_missing_attribute -->
22
<img src="foo" autofocus />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
2+
<img src="foo" autofocus />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script>
22
let count = $state(0);
33
let doubled = $derived(count * 2);
4-
// svelte-ignore static-state-reference
4+
// svelte-ignore state_referenced_locally
55
console.log(count);
6-
// svelte-ignore static-state-reference
6+
// svelte-ignore state_referenced_locally
77
console.log(doubled);
88
</script>

tests/fixtures/rules/no-unused-svelte-ignore/valid/svelte-ignore01-input.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
1+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
22
<div class="dropdown">
33
<label tabindex="0">Click</label>
44
<ul tabindex="0"></ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
2+
<div class="dropdown">
3+
<label tabindex="0">Click</label>
4+
<ul tabindex="0"></ul>
5+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}

tests/fixtures/rules/no-unused-svelte-ignore/valid/svelte-ignore02-input.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
21
TEXT
2+
<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
33
<div class="dropdown">
44
<label tabindex="0">Click</label>
55
<ul tabindex="0"></ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0-0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
2+
TEXT
3+
<div class="dropdown">
4+
<label tabindex="0">Click</label>
5+
<ul tabindex="0"></ul>
6+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": "^3.0.0 || ^4.0.0"
3+
}

0 commit comments

Comments
 (0)