chore: remove some unused code (#9593)

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/9598/head
Rich Harris 1 year ago committed by GitHub
parent cf9130613d
commit 1f4ae5ef45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
chore: remove unused code

@ -58,7 +58,6 @@ export function get_comment_handlers(source) {
* @typedef {import('estree').Comment & {
* start: number;
* end: number;
* has_trailing_newline?: boolean
* }} CommentWithLocation
*/
@ -91,35 +90,26 @@ export function get_comment_handlers(source) {
add_comments(ast) {
if (comments.length === 0) return;
walk(
ast,
{},
{
_(node, { next }) {
let comment;
walk(ast, null, {
_(node, { next }) {
let comment;
while (comments[0] && comments[0].start < node.start) {
comment = /** @type {CommentWithLocation} */ (comments.shift());
const next = comments[0] || node;
comment.has_trailing_newline =
comment.type === 'Line' || /\n/.test(source.slice(comment.end, next.start));
(node.leadingComments ||= []).push(comment);
}
while (comments[0] && comments[0].start < node.start) {
comment = /** @type {CommentWithLocation} */ (comments.shift());
(node.leadingComments ||= []).push(comment);
}
next();
next();
if (comments[0]) {
const slice = source.slice(node.end, comments[0].start);
if (comments[0]) {
const slice = source.slice(node.end, comments[0].start);
if (/^[,) \t]*$/.test(slice)) {
node.trailingComments = [/** @type {CommentWithLocation} */ (comments.shift())];
}
if (/^[,) \t]*$/.test(slice)) {
node.trailingComments = [/** @type {CommentWithLocation} */ (comments.shift())];
}
}
}
);
});
}
};
}

@ -1087,9 +1087,7 @@ function create_block(parent, name, nodes, context) {
/** @type {import('estree').Statement} */ (update).leadingComments = [
{
type: 'Block',
value: ` Update `,
// @ts-expect-error
has_trailing_newline: true
value: ` Update `
}
];
}
@ -1107,9 +1105,7 @@ function create_block(parent, name, nodes, context) {
body[0].leadingComments = [
{
type: 'Block',
value: ` Init `,
// @ts-expect-error
has_trailing_newline: true
value: ` Init `
}
];
}

@ -32,15 +32,11 @@ export function transform_component(analysis, source, options) {
program.body[0].leadingComments = [
{
type: 'Line',
value: ` ${basename} (Svelte v${VERSION})`,
// @ts-ignore
has_trailing_newline: true
value: ` ${basename} (Svelte v${VERSION})`
},
{
type: 'Line',
value: ' Note: compiler output will change before 5.0 is released!',
// @ts-ignore
has_trailing_newline: true
value: ' Note: compiler output will change before 5.0 is released!'
}
];
}
@ -86,9 +82,7 @@ export function transform_module(analysis, source, options) {
program.body[0].leadingComments = [
{
type: 'Block',
value: ` ${basename} generated by Svelte v${VERSION} `,
// @ts-ignore
has_trailing_newline: true
value: ` ${basename} generated by Svelte v${VERSION} `
}
];
}

@ -109,8 +109,7 @@
"type": "Block",
"value": " another comment ",
"start": 163,
"end": 184,
"has_trailing_newline": true
"end": 184
}
]
}
@ -121,8 +120,7 @@
"type": "Line",
"value": " comment",
"start": 141,
"end": 151,
"has_trailing_newline": true
"end": 151
}
]
}
@ -222,8 +220,7 @@
"type": "Line",
"value": " a leading comment",
"start": 10,
"end": 30,
"has_trailing_newline": true
"end": 30
}
],
"trailingComments": [
@ -290,8 +287,7 @@
"type": "Block",
"value": "* a comment ",
"start": 72,
"end": 88,
"has_trailing_newline": true
"end": 88
}
]
}

Loading…
Cancel
Save