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 e338ff4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/language-js/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,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");
if (ast.type === "Block" || ast.type === "CommentBlock") {
const comment = newObj.value.trim();
if (comment === "* @format") {
return null;
// Flow comment
} else 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 e338ff4

Please sign in to comment.