mirror of https://github.com/sveltejs/svelte
chore: add inline new class warning (#9583)
* chore: add inline new class warning * Address feedback * address feedback * more testspull/9592/head
parent
d57eff76ed
commit
eb0b4dc6e5
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
chore: add inline new class warning
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
function bar() {
|
||||
class Foo {
|
||||
foo = $state(0)
|
||||
}
|
||||
const a = new Foo();
|
||||
}
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"code": "inline-new-class",
|
||||
"message": "Creating inline classes will likely cause performance issues. Instead, declare the class at the module-level and create new instances from the class reference.",
|
||||
"start": {
|
||||
"column": 12,
|
||||
"line": 6
|
||||
},
|
||||
"end": {
|
||||
"column": 21,
|
||||
"line": 6
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
class Foo {
|
||||
foo = $state(0)
|
||||
}
|
||||
function bar() {
|
||||
const a = new Foo();
|
||||
}
|
||||
</script>
|
@ -0,0 +1 @@
|
||||
[]
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
function bar() {
|
||||
const a = new class Foo {
|
||||
foo = $state(0)
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"code": "inline-new-class",
|
||||
"message": "Creating inline classes will likely cause performance issues. Instead, declare the class at the module-level and create new instances from the class reference.",
|
||||
"start": {
|
||||
"column": 12,
|
||||
"line": 3
|
||||
},
|
||||
"end": {
|
||||
"column": 3,
|
||||
"line": 5
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,5 @@
|
||||
<script context="module">
|
||||
const a = new class Foo {
|
||||
foo = $state(0)
|
||||
}
|
||||
</script>
|
@ -0,0 +1 @@
|
||||
[]
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
const a = new class {
|
||||
foo = $state(0)
|
||||
}
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"code": "inline-new-class",
|
||||
"message": "Creating inline classes will likely cause performance issues. Instead, declare the class at the module-level and create new instances from the class reference.",
|
||||
"start": {
|
||||
"column": 11,
|
||||
"line": 2
|
||||
},
|
||||
"end": {
|
||||
"column": 2,
|
||||
"line": 4
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in new issue