-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* warn on assignment to const * fix formatting and switch to error * check most local scopes first * fix logic and add more tests * more formatting * Fix broken test * use find_owner instead Co-authored-by: tanhauhau <lhtan93@gmail.com>
- Loading branch information
1 parent
ab1285a
commit 88ed993
Showing
12 changed files
with
207 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"code": "assignment-to-const", | ||
"message": "You are assigning to a const", | ||
"start": { | ||
"line": 14, | ||
"column": 3, | ||
"character": 172 | ||
}, | ||
"end": { | ||
"line": 14, | ||
"column": 10, | ||
"character": 179 | ||
}, | ||
"pos": 172 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script> | ||
const foo = 'hello'; | ||
function shouldNotError() { | ||
let foo = 0; | ||
function inner() { | ||
foo = 1; | ||
} | ||
} | ||
function shouldError() { | ||
function inner() { | ||
foo = 1; | ||
} | ||
} | ||
</script> | ||
|
||
<button on:click={shouldNotError}>click</button> | ||
<button on:click={shouldError}>click</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"code": "assignment-to-const", | ||
"message": "You are assigning to a const", | ||
"start": { | ||
"line": 17, | ||
"column": 2, | ||
"character": 189 | ||
}, | ||
"end": { | ||
"line": 17, | ||
"column": 9, | ||
"character": 196 | ||
}, | ||
"pos": 189 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script> | ||
const foo = 'hello'; | ||
</script> | ||
|
||
<button on:click={() => { | ||
let foo = 0; | ||
|
||
function inner() { | ||
foo = 1; | ||
} | ||
}}> | ||
click | ||
</button> | ||
|
||
<button on:click={() => { | ||
function inner() { | ||
foo = 1; | ||
} | ||
}}> | ||
click | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"code": "assignment-to-const", | ||
"message": "You are assigning to a const", | ||
"start": { | ||
"line": 16, | ||
"column": 2, | ||
"character": 225 | ||
}, | ||
"end": { | ||
"line": 16, | ||
"column": 18, | ||
"character": 241 | ||
}, | ||
"pos": 225 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script> | ||
const immutable = false; | ||
const obj1 = { prop: true }; | ||
const obj2 = { prop: 0 }; | ||
function shouldNotError() { | ||
obj1.prop = false; | ||
} | ||
function shouldNotError2() { | ||
obj2.prop++; | ||
} | ||
function shouldError() { | ||
immutable = true | ||
} | ||
</script> | ||
|
||
<button on:click={shouldNotError}>click</button> | ||
<button on:click={shouldNotError2}>click</button> | ||
<button on:click={shouldError}>click</button> |