* Implement getSupportInfo() and use it for inference
* Add comment with source of languages.yml
* Fix build, pin semver
* Simplify test snapshots
* Remove stray 'type' property
* Fix parser being overwritten
* Don't infer unreleased parser from extension
* Add CLI and docs for support info
* Change badge to say “formatted”
“Styled” sounds like a CSS or CSS-like thing to me — Prettier is a code formatter
* Update code too
* Update the badge at the top too
* Reword badge to “code style: prettier”
* Add option to insert @format pragma if absent
prependPragma --> insertPragma
add tst dir, move stripBom, add to README, update snapshots
remove noise from test + update snapshots
use jest@test new functions, update docs, rerun snapshots
fix accidental upgrade to jest@test
update jest-docblock again to latest with strip()
updated snapshot
* updated snapshots
* revert jest dep change
* apply a trim to parsed comments
* remove empty object
* Revert "apply a trim to parsed comments"
This reverts commit 467f71ce5f4b4f8a1b5c4474ee0484bc96c92141.
* rerun snapshots with proper jest version
* pin jest-docblock to latest @test release
* comment out docs for new feature from readme
* remove leading newlines
* ensure blank line between docblock and rest of file
* remove backtick string
* Add option to require @prettier or @format pragma
Fixes#2397.
Inspired by `eslint-plugin-prettier` and the discussion in #2397, this
implements requiring a special comment pragma to be present in a file's
first comment in order to be formatted.
This will help large codebases gradually transition to prettier over
time without tons of churn or large code reviews.
I implemented this as a standard prettier "option", not just a typical
`argv` flag, as it is relevant in both the cli and the api. This way it
can be provided programmatically, on the command line, or standardized
in a prettierrc file so like the style options, every user can use this
setting consistently and only apply prettier to relevant files, no
mattier their editor integration.
This requires the pragma begin with `@` (in fact it's inserted if the
user doesn't provide it). Currently the usage implies it must be
"prettier" or "format", but it can technically be any value other than
"none", which is similar to the `trailingCommas` option.
cc @vjeux
* Don't quote anything in runPrettier; this is usually handled by a shell
* Make --require-pragma a boolean option
* Use jest-docblock to find pragmas without parsing the ast
* Clarify docs
* includes -> indexOf
* Move test out of integration
Thought the setting wasn't working properly when it didn't apply to self closing elements, and was about to open an issue until I found out it's working as intended.
* Update README.md to add a notice about a limitation using lint-staged
The lint-staged example under pre-commit hooks has a limitation where if you use the [Github Desktop](https://desktop.github.com/) app to commit specific lines, this approach will stage the whole file after regardless. See this [issue](https://github.com/okonet/lint-staged/issues/62) for more info.
* Add back removed empty line
* Remove Github Desktop app reference
* Add comments showing parser arguments
Since this is how they are invoked, the comments make it easier to maintain.
* Use babylon.parseExpression for JSON
See https://github.com/prettier/prettier/issues/2378#issuecomment-314600778
Note that this doesn't yet print comments:
echo '{/*comment*/"K":"V"}' | ./bin/prettier.js --parser json
* Remove parser-json.js
This reduces duplicate code in the built package.
See https://github.com/prettier/prettier/pull/2476#pullrequestreview-50181398
* Add test with block comment in JSON
* Fix test with block comment in JSON
* Add test with line comment in JSON
* Don't build now-redundant parser-json.js