Skip to content

Conversation

josephfrazier
Copy link
Collaborator

That way, we won't have to do any arithmetic on range and cursor locations
when there is a shebang. See here for details:

#1637 (comment)

This required changing comment printing such that comments that are
actually shebangs are just ignored.

That way, we won't have to do any arithmetic on range and cursor
locations when there is a shebang. See here for details:

prettier#1637 (comment)

This required changing comment printing such that comments that are
actually shebangs are just ignored.
src/comments.js Outdated
@@ -801,6 +801,9 @@ function printComment(commentPath) {
return "/*" + comment.value + "*/";
case "CommentLine":
case "Line":
// Don't print the shebang, it's taken care of in index.js
if (options.originalText.slice(util.locStart(comment)).startsWith("#!"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add {} :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, i'll also add an eslint rule in a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome :)

@vjeux
Copy link
Contributor

vjeux commented May 24, 2017

Oh nice! We used to have this crazy setup because the parsers threw syntax errors with shebang. Glad to know they are now handling it :)

Feel free to merge once you address my small nit

josephfrazier added a commit to josephfrazier/prettier that referenced this pull request May 24, 2017
vjeux pushed a commit that referenced this pull request May 24, 2017
@josephfrazier josephfrazier merged commit 9d75159 into prettier:master May 24, 2017
@josephfrazier josephfrazier deleted the print-shebang-comment branch May 24, 2017 22:59
@josephfrazier
Copy link
Collaborator Author

Ah, that's neat to know. Ideally, we could handle actually printing the shebang in printComment, rather than lopping it off beforehand and reattaching it afterward. However, it looks like the flow/typescript parsers don't include the shebang in their ASTs :/

josephfrazier added a commit to josephfrazier/prettier that referenced this pull request Jun 2, 2017
Now we handle actually printing the shebang in `printComment`, rather
than lopping it off beforehand and reattaching it afterward, as
suggested in prettier#1718 (comment)
vjeux pushed a commit that referenced this pull request Jun 2, 2017
* Add shebang comment nodes to Flow/TypeScript ASTs

Now we handle actually printing the shebang in `printComment`, rather
than lopping it off beforehand and reattaching it afterward, as
suggested in #1718 (comment)

* Dedupe AST shebang-insertion code into helper function
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Dec 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants