mirror of https://github.com/sveltejs/svelte
parent
6ac7038e47
commit
d6a9182d21
@ -0,0 +1,34 @@
|
|||||||
|
<script>
|
||||||
|
const immutable1 = false;
|
||||||
|
const immutable2 = 0;
|
||||||
|
|
||||||
|
// these ones should not warn
|
||||||
|
const obj1 = { prop: true };
|
||||||
|
const obj2 = { prop: 0 };
|
||||||
|
|
||||||
|
function func1() {
|
||||||
|
immutable1 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function func2() {
|
||||||
|
immutable2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function func3() {
|
||||||
|
obj1.prop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function func4() {
|
||||||
|
obj2.prop++;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={func1}>click</button>
|
||||||
|
<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={() => immutable2++}>click</button>
|
||||||
|
<button on:click={() => obj1.prop = false}>click</button>
|
||||||
|
<button on:click={() => obj2.prop++}>click</button>
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"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