mirror of https://github.com/sveltejs/svelte
parent
d6a9182d21
commit
d0619dcd84
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "assignment-to-const",
|
||||||
|
"message": "You are assigning to a const",
|
||||||
|
"start": {
|
||||||
|
"line": 13,
|
||||||
|
"column": 24,
|
||||||
|
"character": 282
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 13,
|
||||||
|
"column": 35,
|
||||||
|
"character": 293
|
||||||
|
},
|
||||||
|
"pos": 282
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
<script>
|
||||||
|
const immutable = 0;
|
||||||
|
|
||||||
|
const obj1 = { prop: true };
|
||||||
|
const obj2 = { prop: 0 }
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- should not error -->
|
||||||
|
<button on:click={() => obj1.prop = false}>click</button>
|
||||||
|
<button on:click={() => obj2.prop++}>click</button>
|
||||||
|
|
||||||
|
<!-- should error -->
|
||||||
|
<button on:click={() => immutable++}>click</button>
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "assignment-to-const",
|
||||||
|
"message": "You are assigning to a const",
|
||||||
|
"start": {
|
||||||
|
"line": 16,
|
||||||
|
"column": 2,
|
||||||
|
"character": 237
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 16,
|
||||||
|
"column": 18,
|
||||||
|
"character": 253
|
||||||
|
},
|
||||||
|
"pos": 237
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -1,34 +1,24 @@
|
|||||||
<script>
|
<script>
|
||||||
const immutable1 = false;
|
const immutable = false;
|
||||||
const immutable2 = 0;
|
|
||||||
|
|
||||||
// these ones should not warn
|
|
||||||
const obj1 = { prop: true };
|
const obj1 = { prop: true };
|
||||||
const obj2 = { prop: 0 };
|
const obj2 = { prop: 0 };
|
||||||
|
|
||||||
function func1() {
|
function funcShouldNotError() {
|
||||||
immutable1 = true
|
obj1.prop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function func2() {
|
function funcShouldNotError2() {
|
||||||
immutable2++;
|
obj2.prop++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function func3() {
|
function funcShouldError() {
|
||||||
obj1.prop = false;
|
immutable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function func4() {
|
|
||||||
obj2.prop++;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<button on:click={func1}>click</button>
|
</script>
|
||||||
<button on:click={func2}>click</button>
|
|
||||||
<button on:click={func3}>click</button>
|
|
||||||
<button on:click={func4}>click</button>
|
|
||||||
|
|
||||||
<button on:click={() => immutable2 = true}>click</button>
|
<button on:click={funcShouldNotError}>click</button>
|
||||||
<button on:click={() => immutable2++}>click</button>
|
<button on:click={funcShouldNotError2}>click</button>
|
||||||
<button on:click={() => obj1.prop = false}>click</button>
|
<button on:click={funcShouldError}>click</button>
|
||||||
<button on:click={() => obj2.prop++}>click</button>
|
|
||||||
|
|||||||
@ -1,62 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"code": "assignment-to-const",
|
|
||||||
"message": "You are assigning to a const",
|
|
||||||
"start": {
|
|
||||||
"line": 31,
|
|
||||||
"column": 24,
|
|
||||||
"character": 512
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 31,
|
|
||||||
"column": 41,
|
|
||||||
"character": 529
|
|
||||||
},
|
|
||||||
"pos": 512
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "assignment-to-const",
|
|
||||||
"message": "You are assigning to a const",
|
|
||||||
"start": {
|
|
||||||
"line": 32,
|
|
||||||
"column": 24,
|
|
||||||
"character": 570
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 32,
|
|
||||||
"column": 36,
|
|
||||||
"character": 582
|
|
||||||
},
|
|
||||||
"pos": 570
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "assignment-to-const",
|
|
||||||
"message": "You are assigning to a const",
|
|
||||||
"start": {
|
|
||||||
"line": 10,
|
|
||||||
"column": 2,
|
|
||||||
"character": 171
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 10,
|
|
||||||
"column": 19,
|
|
||||||
"character": 188
|
|
||||||
},
|
|
||||||
"pos": 171
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "assignment-to-const",
|
|
||||||
"message": "You are assigning to a const",
|
|
||||||
"start": {
|
|
||||||
"line": 14,
|
|
||||||
"column": 2,
|
|
||||||
"character": 215
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 14,
|
|
||||||
"column": 14,
|
|
||||||
"character": 227
|
|
||||||
},
|
|
||||||
"pos": 215
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Loading…
Reference in new issue