Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(language-js/pragma.js): support pragma in comments #5357

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jedwards1211
Copy link

@jedwards1211 jedwards1211 commented Nov 6, 2018

fix #5352

Added code to language-js/pragma.js that uses some regex magic to scan through leading single-line or multiline comments in a file (that is, until it reaches something that's not a comment or whitespace) and check if any of those comments contains @prettier or @format surrounded by whitespace or line boundaries.

EDIT: updated to skip a hashbang on the first line as well.

Thus it's now possible to trigger prettier with /* @prettier */, // @prettier, /* @flow @prettier */, etc., in addition to the existing support for the pragma inside a docblock.

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.

Try the playground for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

requirePragma doesn't work if @prettier pragma comes after other pragmas like @flow
1 participant