* feat: support YAML * fix: do not indent sequence in mappingValue * docs: add yaml to index.md * fix: reduce `SyntaxError: Node#parse consumed no characters` * chore: remove old-build and new-worker.js * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor * fix: no space after `<<` * fix: add yaml to standalone test * test: add tests * fix: next empty line in flow collection * fix: tabs are not allowed http://yaml.org/spec/1.2/spec.html#space/indentation/ * fix: update parser * feat: rewrite the mappingItem logic * feat: indent sequence in mapping * feat(doc): add ifBreak#groupId and group#id * chore: fix node 4 * chore: add tools_yaml.svg * chore: remove resolved TODO * refactor: remove unnecessary workaround * chore(worker): importScriptOnce * chore(build): rename with babelPlugins * make it rollup compatible * feat: support singleQuote * refactor
2.4 KiB
id, title
| id | title |
|---|---|
| index | What is Prettier? |
Prettier is an opinionated code formatter with support for:
- JavaScript, including ES2017
- JSX
- Flow
- TypeScript
- CSS, Less, and SCSS
- JSON
- GraphQL
- Markdown, including GFM
- YAML
It removes all original styling* and ensures that all outputted code conforms to a consistent style. (See this blog post)
Prettier takes your code and reprints it from scratch by taking the line length into account.
For example, take the following code:
foo(arg1, arg2, arg3, arg4);
It fits in a single line so it's going to stay as is. However, we've all run into this situation:
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
Suddenly our previous format for calling function breaks down because this is too long. Prettier is going to do the painstaking work of reprinting it like that for you:
foo(
reallyLongArg(),
omgSoManyParameters(),
IShouldRefactorThis(),
isThereSeriouslyAnotherOne()
);
Prettier enforces a consistent code style (i.e. code formatting that won't affect the AST) across your entire codebase because it disregards the original styling* by parsing it away and re-printing the parsed AST with its own rules that take the maximum line length into account, wrapping code when necessary.
If you want to learn more, these two conference talks are great introductions:
Footnotes
* Well actually, some original styling is preserved when practical—see empty lines and multi-line objects.

