prettier с фиксом для поддержки скобок с новой строки
 
 
 
 
 
 
Go to file
Christopher Chedeau 0af81c7695
Improve union types with leading comments (#5575)
We're running into this issue at Facebook because `// flowfixme` ignores the very next line, but in this case an empty line is added in-between which breaks the fixme.

Ideally the solution is to avoid adding a newline and we'd call it a day. Unfortunately it is tricky to implement in this particular case. The comment is already printed, including its \n. Yet, we want to indent the block and the only way to convince the doc printer to do so is to add an indent group --before-- the \n is printed, otherwise it's just going to indent on the next \n.

So this PR changes the output from one bad way to another, but the new way has the benefit of not breaking flow for Facebook, which makes our internal teams happier.

Note that the way we print the same construct with `&` is broken in the same way as with this PR. https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEBbAngNQEMAbAVzkwF5MAKME4+4xhpl5tmgDgHYA2LgE5+g3gP5CRY6cL6iJE2fL4BKJAB0ombTt17tAegOYAwhGzYEMTftu7oFAGSYYAdwjOYACwBOTzABWACYA1gAeXgBmxCFowVEA5jEBaEGJyV6pIdEBCZkhQQGJIcQpXkGRCSFFWaWRXlWlaOWVwZElCUUlAZgqANwgADQgEAAOMACW6MighD4+EK4ACnMIaMgghABuEBNBQyAARj6EYCFwMADKo6cTUAnIMD7kw14w2MQA6l4T8Gg3YDglzWvwmW1+uA2YDQ62GdzQcB8MCWJwS2EIyEiJARwxSYQAQiczhdLoRLAAZO5wTHYuC4tBhS53JJwACKpAg8BpxBxIBuPgRPg2h0Ih1wxGgB1GPjuME+e28yC4AAZhtKIAjPidRhtpXBBVtqcM-ABHUgTPwowhojFILE8ukgBHYCaPZ6OtDM4hsjlcu204YwUXyoKKpAAJkDJwmxGZZgstpAUAcB1ICIAKqL1v6HQBfXNAA

Fixes #5572
2018-11-28 10:30:51 -08:00
.azure-pipelines chore(build): es5 compatibility for browser (#5560) 2018-11-28 12:52:05 +08:00
.circleci Report test summaries to CircleCI (#4704) 2018-07-07 12:11:04 -04:00
.github Release 1.15.2 2018-11-11 01:08:51 +08:00
bin refactor(cli): separate files and make it pure as possible (#2730) 2017-09-03 19:21:06 +10:00
docs Add more information on how to configure ALE (#5454) 2018-11-12 22:01:30 +02:00
scripts chore(build): es5 compatibility for browser (#5560) 2018-11-28 12:52:05 +08:00
src Improve union types with leading comments (#5575) 2018-11-28 10:30:51 -08:00
tests Improve union types with leading comments (#5575) 2018-11-28 10:30:51 -08:00
tests_config test: improve snapshots (#5521) 2018-11-25 16:21:14 +08:00
tests_integration fix: update editorconfig-to-prettier (#5550) 2018-11-26 13:08:52 +08:00
website Bump Prettier dependency to 1.15.0 2018-11-07 09:12:25 +08:00
.codecov.yml Improve coverage and remove some dead code (#2504) 2017-07-17 23:31:42 +10:00
.eslintignore Introduce Release script (#4631) 2018-06-05 16:37:52 -03:00
.eslintrc.yml lint fixes 2018-04-17 18:09:36 -03:00
.flowconfig Build the dist/ with rollup (#1794) 2017-05-28 21:49:41 -07:00
.gitattributes Fix tests for Windows and add Azure Pipelines for cross platform CI (#5410) 2018-11-14 07:55:50 -05:00
.gitignore Report test summaries to CircleCI (#4704) 2018-07-07 12:11:04 -04:00
.ignore Remove .npmignore and update .ignore (#2560) 2017-07-31 08:47:00 +10:00
.pre-commit-hooks.yaml docs(blog): 1.15 release (#5296) 2018-11-07 09:09:04 +08:00
.prettierignore Implement getSupportInfo() and use it for inference (#3033) 2017-11-03 18:06:25 +11:00
.travis.yml Travis - Allow failures in Node 6 (#4690) 2018-06-14 09:55:31 -03:00
.yarnrc chore(yarn): disable integrity migration 2018-10-27 21:01:26 +08:00
CHANGELOG.md Release 1.15.2 2018-11-11 01:08:51 +08:00
CONTRIBUTING.md docs(perf): add performance section to CONTRIBUTING.md (#4846) 2018-07-23 06:20:28 -04:00
LICENSE Happy new year 2018! (#3620) 2018-01-01 00:41:21 +01:00
README.md Replace Appveyor badge with Azure Pipelines badge (#5492) 2018-11-15 19:35:51 -05:00
azure-pipelines.yml chore(build): es5 compatibility for browser (#5560) 2018-11-28 12:52:05 +08:00
commands.md Add a new `trim` command to trim whitespaces in the current line (#4772) 2018-10-06 20:18:52 +08:00
index.js refactor: move index.js and standalone.js to src (#5054) 2018-09-06 13:51:18 +08:00
jest.config.js Fix tests for Windows and add Azure Pipelines for cross platform CI (#5410) 2018-11-14 07:55:50 -05:00
package.json chore(build): es5 compatibility for browser (#5560) 2018-11-28 12:52:05 +08:00
standalone.js refactor: move index.js and standalone.js to src (#5054) 2018-09-06 13:51:18 +08:00
yarn.lock feat(typescript): support BigInt (#5546) 2018-11-27 16:53:34 +08:00

README.md

Prettier Banner

Opinionated Code Formatter

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML
Your favorite language?

Travis CI Build Status CircleCI Build Status Azure Pipelines Build Status Codecov Coverage Status Blazing Fast
npm version weekly downloads from npm code style: prettier Chat on Gitter Follow Prettier on Twitter

Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

Input

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Output

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne()
);

Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!


Documentation

Install · Options · CLI · API

Playground


Badge

Show the world you're using Prettiercode style: prettier

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Contributing

See CONTRIBUTING.md.