Skip to content

Commit e00d318

Browse files
committed
fix: lint
1 parent d8f4cdd commit e00d318

File tree

1 file changed

+32
-8
lines changed
  • packages/svelte/src/compiler/migrate

1 file changed

+32
-8
lines changed

packages/svelte/src/compiler/migrate/index.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,8 @@ function extract_type_and_comment(declarator, state, path) {
15011501
const trailing_comment_node = /** @type {Node} */ (parent)?.trailingComments?.at(0);
15021502
const trailing_comment_start = /** @type {any} */ (trailing_comment_node)?.start;
15031503
const trailing_comment_end = /** @type {any} */ (trailing_comment_node)?.end;
1504-
let trailing_comment = trailing_comment_node && str.original.substring(trailing_comment_start, trailing_comment_end);
1504+
let trailing_comment =
1505+
trailing_comment_node && str.original.substring(trailing_comment_start, trailing_comment_end);
15051506

15061507
if (trailing_comment_node) {
15071508
str.update(trailing_comment_start, trailing_comment_end, '');
@@ -1513,7 +1514,11 @@ function extract_type_and_comment(declarator, state, path) {
15131514
while (str.original[start] === ' ') {
15141515
start++;
15151516
}
1516-
return { type: str.original.substring(start, declarator.id.typeAnnotation.end), comment, trailing_comment };
1517+
return {
1518+
type: str.original.substring(start, declarator.id.typeAnnotation.end),
1519+
comment,
1520+
trailing_comment
1521+
};
15171522
}
15181523

15191524
let cleaned_comment_arr = comment
@@ -1535,7 +1540,7 @@ function extract_type_and_comment(declarator, state, path) {
15351540
let cleaned_comment = cleaned_comment_arr
15361541
?.slice(0, first_at_comment !== -1 ? first_at_comment : cleaned_comment_arr.length)
15371542
.join('\n');
1538-
1543+
15391544
let cleaned_comment_arr_trailing = trailing_comment
15401545
?.split('\n')
15411546
.map((line) =>
@@ -1551,17 +1556,28 @@ function extract_type_and_comment(declarator, state, path) {
15511556
.replace(/^\*\s*/g, '')
15521557
)
15531558
.filter(Boolean);
1554-
const first_at_comment_trailing = cleaned_comment_arr_trailing?.findIndex((line) => line.startsWith('@'));
1559+
const first_at_comment_trailing = cleaned_comment_arr_trailing?.findIndex((line) =>
1560+
line.startsWith('@')
1561+
);
15551562
let cleaned_comment_trailing = cleaned_comment_arr_trailing
1556-
?.slice(0, first_at_comment_trailing !== -1 ? first_at_comment_trailing : cleaned_comment_arr_trailing.length)
1563+
?.slice(
1564+
0,
1565+
first_at_comment_trailing !== -1
1566+
? first_at_comment_trailing
1567+
: cleaned_comment_arr_trailing.length
1568+
)
15571569
.join('\n');
15581570

15591571
// try to find a comment with a type annotation, hinting at jsdoc
15601572
if (parent?.type === 'ExportNamedDeclaration' && comment_node) {
15611573
state.has_type_or_fallback = true;
15621574
const match = /@type {(.+)}/.exec(comment_node.value);
15631575
if (match) {
1564-
return { type: match[1], comment: cleaned_comment, trailing_comment: cleaned_comment_trailing };
1576+
return {
1577+
type: match[1],
1578+
comment: cleaned_comment,
1579+
trailing_comment: cleaned_comment_trailing
1580+
};
15651581
}
15661582
}
15671583

@@ -1570,11 +1586,19 @@ function extract_type_and_comment(declarator, state, path) {
15701586
state.has_type_or_fallback = true; // only assume type if it's trivial to infer - else someone would've added a type annotation
15711587
const type = typeof declarator.init.value;
15721588
if (type === 'string' || type === 'number' || type === 'boolean') {
1573-
return { type, comment: state.uses_ts ? comment : cleaned_comment, trailing_comment: state.uses_ts ? trailing_comment : cleaned_comment_trailing };
1589+
return {
1590+
type,
1591+
comment: state.uses_ts ? comment : cleaned_comment,
1592+
trailing_comment: state.uses_ts ? trailing_comment : cleaned_comment_trailing
1593+
};
15741594
}
15751595
}
15761596

1577-
return { type: 'any', comment: state.uses_ts ? comment : cleaned_comment, trailing_comment: state.uses_ts ? trailing_comment : cleaned_comment_trailing };
1597+
return {
1598+
type: 'any',
1599+
comment: state.uses_ts ? comment : cleaned_comment,
1600+
trailing_comment: state.uses_ts ? trailing_comment : cleaned_comment_trailing
1601+
};
15781602
}
15791603

15801604
// Ensure modifiers are applied in the same order as Svelte 4

0 commit comments

Comments
 (0)