code-red
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "code-red", | ||
"description": "code-red", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"repository": "Rich-Harris/code-red", | ||
@@ -6,0 +6,0 @@ "main": "dist/code-red.cjs", |
@@ -154,3 +154,3 @@ import * as acorn from 'acorn'; | ||
walk(node, { | ||
return walk(node, { | ||
enter, | ||
@@ -257,3 +257,2 @@ | ||
// @ts-ignore | ||
leave(node); | ||
@@ -277,7 +276,7 @@ } | ||
try { | ||
const ast = /** @type {any} */ ( | ||
let ast = /** @type {any} */ ( | ||
acorn.parse(str, acorn_opts(comments, str)) | ||
); | ||
inject(str, ast, values, comments); | ||
ast = inject(str, ast, values, comments); | ||
@@ -303,3 +302,3 @@ return ast.body; | ||
try { | ||
const expression = | ||
let expression = | ||
/** @type {Expression & { start: Number, end: number }} */ ( | ||
@@ -313,3 +312,5 @@ acorn.parseExpressionAt(str, 0, acorn_opts(comments, str)) | ||
inject(str, expression, values, comments); | ||
expression = /** @type {Expression & { start: Number, end: number }} */ ( | ||
inject(str, expression, values, comments) | ||
); | ||
@@ -335,7 +336,7 @@ return expression; | ||
try { | ||
const expression = /** @type {any} */ ( | ||
let expression = /** @type {any} */ ( | ||
acorn.parseExpressionAt(str, 0, acorn_opts(comments, str)) | ||
); | ||
inject(str, expression, values, comments); | ||
expression = inject(str, expression, values, comments); | ||
@@ -342,0 +343,0 @@ return expression.properties[0]; |
@@ -384,3 +384,3 @@ // heavily based on https://github.com/davidbonnet/astring | ||
EmptyStatement(node, state) { | ||
return []; | ||
return [c(';')]; | ||
}, | ||
@@ -491,6 +491,7 @@ | ||
if (node.argument) { | ||
const contains_comment = node.argument.leadingComments && node.argument.leadingComments.some((/** @type import('../utils/comments.js').CommentWithLocation */ comment) => comment.has_trailing_newline); | ||
return [ | ||
c('return '), | ||
c(contains_comment ? 'return (' : 'return '), | ||
...handle(node.argument, state), | ||
c(';') | ||
c(contains_comment ? ');' : ';') | ||
]; | ||
@@ -497,0 +498,0 @@ } else { |
Sorry, the diff of this file is not supported yet
4224
139324
14