Skip to content

Commit add5b84

Browse files
committed
test(prefer-svelte-reactivity): added tests for encapsulated local variables
1 parent e0d6ec8 commit add5b84

File tree

38 files changed

+352
-0
lines changed

38 files changed

+352
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"options": [{ "ignoreEncapsulatedLocalVariables": false }]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Found a mutable instance of the built-in Set class. Use SvelteSet instead.
2+
line: 3
3+
column: 20
4+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
const fn = () => {
3+
const variable = new Set([1, 2, 1, 3, 3]);
4+
variable.add(42);
5+
return 42;
6+
}
7+
</script>
8+
9+
{fn()}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
class A {
3+
#variable = new Set([1, 2, 1, 3, 3]);
4+
5+
fn() {
6+
this.#variable.add(42);
7+
return 42;
8+
}
9+
}
10+
11+
const a = new A();
12+
</script>
13+
14+
{a.fn()}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script>
2+
class A {
3+
#variable = new Set([1, 2, 1, 3, 3]);
4+
5+
#fn() {
6+
this.#variable.add(42);
7+
return this.#variable;
8+
}
9+
10+
fn2() {
11+
this.#fn();
12+
return 42;
13+
}
14+
}
15+
16+
const a = new A();
17+
</script>
18+
19+
{a.fn2()}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Found a mutable instance of the built-in Set class. Use SvelteSet instead.
2+
line: 3
3+
column: 22
4+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
class A {
3+
private variable = new Set([1, 2, 1, 3, 3]);
4+
5+
public fn() {
6+
this.variable.add(42);
7+
return 42;
8+
}
9+
}
10+
11+
const a = new A();
12+
</script>
13+
14+
{a.fn()}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Found a mutable instance of the built-in Set class. Use SvelteSet instead.
2+
line: 3
3+
column: 22
4+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script lang="ts">
2+
class A {
3+
private variable = new Set([1, 2, 1, 3, 3]);
4+
5+
private fn() {
6+
this.variable.add(42);
7+
return this.variable;
8+
}
9+
10+
public fn2() {
11+
this.fn();
12+
return 42;
13+
}
14+
}
15+
16+
const a = new A();
17+
</script>
18+
19+
{a.fn2()}

0 commit comments

Comments
 (0)