mirror of https://github.com/sveltejs/svelte
feat: warn on obvious legacy component instantiation (#12648)
Adds a compiler warning that warns about legacy component instantiation (i.e. using `new Component(..)`). This won't catch all cases, but the most obvious ones which probably make up ~80%animation-params
parent
85f2f161ed
commit
363535c849
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Foo, { Bar } from './Somewhere.svelte';
|
||||
import Baz from './somewhereelse';
|
||||
|
||||
let Buzz;
|
||||
|
||||
new Foo({ target: null });
|
||||
new Foo({}); // also a false negative to be really sure we don't get false positives
|
||||
new Foo();
|
||||
new Bar();
|
||||
new Baz();
|
||||
new Buzz();
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"code": "legacy_component_creation",
|
||||
"message": "Svelte 5 components are no longer classes. Instantiate them using `mount` or `hydrate` (imported from 'svelte') instead.",
|
||||
"start": {
|
||||
"column": 1,
|
||||
"line": 7
|
||||
},
|
||||
"end": {
|
||||
"column": 26,
|
||||
"line": 7
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in new issue