Skip to content

Commit

Permalink
Flow and insertPragma
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Nov 2, 2020
1 parent dba72f4 commit f52eb3d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/language-js/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ function clean(ast, newObj, parent) {
}

if (ast.type === "Line" || ast.type === "CommentLine") {
newObj.value = newObj.value.trimEnd();
}
if ( ast.type === "Block" || ast.type === "CommentBlock") {
newObj.value = newObj.value.split("\n").map(line => line.trim()).join("\n");
newObj.value = ast.value.trimEnd();
}
if (ast.type === "Block" || ast.type === "CommentBlock") {
const comment = ast.value.trim();
// Flow comment
if (comment.startsWith("::") || comment === "* @format") {
newObj.value = "";
} else {
const lines = comment
.split("\n")
.map((line) => line.trim())
.filter((line) => line === "* @format");
newObj.value = lines.join("\n");
}
}

if (
Expand Down

0 comments on commit f52eb3d

Please sign in to comment.