Trim trailing whitespace from comments, closes #2422 (#2494)

This commit is contained in:
Lucas Azzola authored and GitHub committed 2017-07-16 17:45:27 +10:00
1 parent 123d350524
commit 00d9aa208e
3 files changed
+23 -3

No files matched your search

+3 -3
View File
@@ -831,7 +831,7 @@ function printComment(commentPath, options) {
switch (comment.type || comment.kind) {
case "Comment":
return "#" + comment.value;
return "#" + comment.value.trimRight();
case "CommentBlock":
case "Block":
return "/*" + comment.value + "*/";
@@ -839,9 +839,9 @@ function printComment(commentPath, options) {
case "Line":
// Print shebangs with the proper comment characters
if (options.originalText.slice(util.locStart(comment)).startsWith("#!")) {
return "#!" + comment.value;
return "#!" + comment.value.trimRight();
}
return "//" + comment.value;
return "//" + comment.value.trimRight();
default:
throw new Error("Not a comment: " + JSON.stringify(comment));
}
@@ -1249,6 +1249,21 @@ d //comment
`;
exports[`trailing_space.js 1`] = `
#!/there/is-space-here->
// Do not trim trailing whitespace from this source file!
// There is some space here ->
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/there/is-space-here->
// Do not trim trailing whitespace from this source file!
// There is some space here ->
`;
exports[`try.js 1`] = `
// comment 1
try {
+5
View File
@@ -0,0 +1,5 @@
#!/there/is-space-here->
// Do not trim trailing whitespace from this source file!
// There is some space here ->