File tree 3 files changed +12
-6
lines changed
src/compiler/phases/2-analyze
tests/validator/samples/component-legacy-instantiation
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -366,7 +366,11 @@ const validation = {
366
366
if (
367
367
node . expression . type === 'NewExpression' &&
368
368
node . expression . callee . type === 'Identifier' &&
369
- node . expression . arguments . length === 1
369
+ node . expression . arguments . length === 1 &&
370
+ node . expression . arguments [ 0 ] . type === 'ObjectExpression' &&
371
+ node . expression . arguments [ 0 ] . properties . some (
372
+ ( p ) => p . type === 'Property' && p . key . type === 'Identifier' && p . key . name === 'target'
373
+ )
370
374
) {
371
375
const binding = state . scope . get ( node . expression . callee . name ) ;
372
376
if ( binding ?. kind === 'normal' && binding . declaration_kind === 'import' ) {
Original file line number Diff line number Diff line change 4
4
5
5
let Buzz;
6
6
7
- new Foo ({});
7
+ new Foo ({ target: null });
8
+ new Foo ({}); // also a false negative to be really sure we don't get false positives
9
+ new Foo ();
8
10
new Bar ();
9
11
new Baz ();
10
12
new Buzz ();
Original file line number Diff line number Diff line change 1
1
[
2
2
{
3
3
"code" : " legacy_component_creation" ,
4
- "end" : {
5
- "column" : 12 ,
6
- "line" : 7
7
- },
8
4
"message" : " Svelte 5 components are no longer classes. Instantiate them using `mount` or `hydrate` (imported from 'svelte') instead." ,
9
5
"start" : {
10
6
"column" : 1 ,
11
7
"line" : 7
8
+ },
9
+ "end" : {
10
+ "column" : 26 ,
11
+ "line" : 7
12
12
}
13
13
}
14
14
]
You can’t perform that action at this time.
0 commit comments