mirror of https://github.com/sveltejs/svelte
fix: warn against accidental global event referenced (#10442)
* fix: warn against accidental global event referenced closes #10393 * remove list * remove else * tweak * update test --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/10510/head
parent
49ad7f9589
commit
71601ba2e5
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: warn against accidental global event referenced
|
@ -0,0 +1,3 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({});
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
let onclick;
|
||||
</script>
|
||||
|
||||
<button {onclick}></button>
|
||||
<button onclick={onclick}></button>
|
||||
|
||||
<button {onkeydown}></button>
|
||||
<button onkeydown={onkeydown}></button>
|
@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"code": "global-event-reference",
|
||||
"message": "You are referencing globalThis.onkeydown. Did you forget to declare a variable with that name?",
|
||||
"start": {
|
||||
"column": 8,
|
||||
"line": 8
|
||||
},
|
||||
"end": {
|
||||
"column": 19,
|
||||
"line": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "global-event-reference",
|
||||
"message": "You are referencing globalThis.onkeydown. Did you forget to declare a variable with that name?",
|
||||
"start": {
|
||||
"column": 8,
|
||||
"line": 9
|
||||
},
|
||||
"end": {
|
||||
"column": 29,
|
||||
"line": 9
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in new issue