Skip to content

Commit

Permalink
fixed the error when comment comes before statement
Browse files Browse the repository at this point in the history
  • Loading branch information
cantfindname committed Mar 5, 2024
1 parent 40a0342 commit cec667e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/esm/standalone.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29151,7 +29151,7 @@ var require_block = __commonJS2({
if (isNonEmptyArray(node.body) && options.multiEmptyLine) {
const blockStartingLine = node.loc.start.line;
const statementStartingLine = node.body[0].loc.start.line;
if (hasComment(node.body[0])) {
if (hasComment(node.body[0]) && node.body[0].comments[0].loc.start.line < statementStartingLine) {
const commentStartLine = node.body[0].comments[0].loc.start.line;
for (let i = blockStartingLine + 1; i < commentStartLine; i++) {
parts.push(hardline);
Expand All @@ -29177,7 +29177,7 @@ var require_block = __commonJS2({
const bodyCount = node.body.length;
const lastBody = node.body[bodyCount - 1];
const statementEndingLine = lastBody.loc.end.line;
if (hasComment(node.body[bodyCount - 1])) {
if (hasComment(node.body[bodyCount - 1]) && lastBody.comments[lastBody.comments.length - 1].loc.end.line > statementEndingLine) {
const commentCount = lastBody.comments.length;
const commentStartLine = lastBody.comments[commentCount - 1].loc.end.line;
for (let i = commentStartLine + 1; i < blockEndingLine; i++) {
Expand Down
Loading

0 comments on commit cec667e

Please sign in to comment.