Commit Graph

2740 Commits (907c5cab72f1bcd3d591f1ac903710e3ec4066c0)

Author SHA1 Message Date
Ika 907c5cab72
chore(yarn): disable integrity migration
Yarn v1.10 adds `integrity`s but v1.9 removes them.
Add this option to prevent them from adding unnecessary diffs all the time.
This is the default value for Yarn v1.12+ (ref: yarnpkg/yarn#6465).
2018-10-27 21:01:26 +08:00
Jordan Brown b861448dbf Pretty print inexact (#5304) 2018-10-26 21:05:42 +03:00
Jordan Brown 5d47e02f64 Update flow parser to 0.84.0 (#5303) 2018-10-26 22:14:47 +08:00
Beau Smith 6e0de08122 User can copy JSON config from Playground. (#5295) 2018-10-25 17:41:08 -04:00
Aquib Master 1234ceb1d6 Fix flow extends not breaking out into new lines (#5244) 2018-10-25 10:49:53 -04:00
Jaiden Gerig 2cc32da5af Fixed unstable while comment (#5251)
* Fixed unstable while comment

* Aligned while loop formatting more closely with if statment formatting
2018-10-25 10:48:09 -04:00
Ashwin Bhat 253716dd49 Fix Flow generic comment positioning (#5290)
* add test for ensuring that calls with zero arguments look right
2018-10-25 08:44:16 -04:00
Jed Fox 6a174654a4 Fix indentation of block comments where every line starts with a star (#5206)
Previously this was done only for JSDoc comments. Now it's done in a few additional cases.
2018-10-23 21:04:24 +02:00
Ashwin Bhat 4d4fab39fe Add support for flow typecast comments (#5280)
* Add support for flow typecast comments

* Allow whitespace between comment start and colon

Also rename flow-comments.js to utils.js

* fix bug where type annotations could be accidentally created

* use better regex in detecting flow comment whitespace

* fix comment in utils.js

* simplify conditionals and improve comments

* fix lint error
2018-10-23 10:46:20 -04:00
Gilles Debunne 559831d08e Update husky integration code for husky v1.0.0 (#5266)
Latest husky (version 1.0.0) moved its hooks config from the `scripts` field to a new `husky` field in `package.json` ([ChangeLog](https://github.com/typicode/husky/blob/master/CHANGELOG.md)).

The `scripts` syntax described here, although shorter, will be deprecated soon. This change replaces it with the new husky syntax.

The new syntax is already used in [precommit.md](https://github.com/prettier/prettier/blob/master/docs/precommit.md).
2018-10-21 23:28:19 +08:00
Lucas Azzola d1d1f17157
Update some plugin links (#5282)
Looks like they were overlooked.
2018-10-20 12:40:09 +11:00
Lucas Duailibe 62e4654e60
Respect original text decorator order (#5207) 2018-10-17 14:14:59 -03:00
Evilebot Tnawi 023a8b78df feat: more shared utils for plugins (#5254) 2018-10-17 07:53:38 -07:00
Chris Adams 4cc0363b40 Remove HTML from pre-commit hooks until available (#5274)
The pre-commit hook registers for HTML files but that will always fail until #5098 is completed. This means that anyone following [the instructions](https://prettier.io/docs/en/precommit.html#option-3-pre-commit-https-githubcom-pre-commit-pre-commit) will have the hook fail any time they attempt to commit an HTML file.
2018-10-17 08:40:04 +08:00
Raphael Boidol 59c075b311 [ImgBot] optimizes images (#5261)
*Total -- 1,155.42kb -> 742.94kb (35.7%)

/website/static/images/users/iress-200x100.png -- 78.46kb -> 4.68kb (94.03%)
/website/static/images/users/assertible-200x100.png -- 31.41kb -> 2.68kb (91.47%)
/website/static/images/users/sevenspan-200x100.png -- 19.97kb -> 5.77kb (71.09%)
/website/static/icon.png -- 4.47kb -> 1.72kb (61.45%)
/website/static/images/users/zipch-200x100.png -- 3.91kb -> 1.64kb (58.04%)
/website/static/images/users/discord-200x100.png -- 3.18kb -> 1.42kb (55.5%)
/website/static/images/users/nrwl-200x100.png -- 25.42kb -> 11.47kb (54.89%)
/website/static/images/users/loyaltylion-200x100.png -- 5.14kb -> 2.49kb (51.58%)
/website/static/images/users/drizly-200x100.png -- 7.02kb -> 3.44kb (50.94%)
/website/static/images/users/mathrioshka-200x100.png -- 37.09kb -> 19.25kb (48.1%)
/website/static/images/users/troops-200x100.png -- 6.75kb -> 3.54kb (47.61%)
/website/static/images/languages/markdown-128px.png -- 3.66kb -> 1.93kb (47.29%)
/website/static/images/users/eyesquare-200x100.png -- 10.26kb -> 5.49kb (46.53%)
/website/static/images/editors/webstorm-128px.png -- 6.64kb -> 3.77kb (43.18%)
/website/static/images/editors/atom-128px.png -- 8.66kb -> 5.07kb (41.45%)
/website/static/images/users/lifesum-200x100.png -- 12.70kb -> 7.45kb (41.33%)
/website/static/images/users/brigad-200x100.png -- 13.67kb -> 8.06kb (41.02%)
/website/static/images/users/holidaycheck-200x100.png -- 13.79kb -> 8.30kb (39.81%)
/website/static/images/users/outreach-200x100.png -- 8.52kb -> 5.36kb (37.13%)
/website/static/images/users/hudl-200x100.png -- 8.77kb -> 5.56kb (36.66%)
/website/static/images/editors/visualstudio-128px.png -- 3.13kb -> 1.98kb (36.62%)
/website/static/images/languages/js-128px.png -- 3.34kb -> 2.12kb (36.62%)
/website/blog/assets/github-diff-ternary-in-jsx.png -- 67.71kb -> 44.43kb (34.37%)
/website/static/images/users/getonboard-200x100.png -- 5.53kb -> 3.74kb (32.43%)
/website/static/images/users/hackclub-200x100.png -- 7.90kb -> 5.44kb (31.13%)
/website/static/prettier.png -- 16.74kb -> 11.61kb (30.62%)
/docs/assets/youtube-cover/a-prettier-printer-by-james-long-on-react-conf-2017.png -- 328.21kb -> 230.23kb (29.85%)
/website/static/images/users/transloadit-200x100.png -- 10.47kb -> 7.47kb (28.66%)
/website/static/images/users/paypal-200x100.png -- 12.50kb -> 8.94kb (28.5%)
/website/static/images/users/mongodb-200x100.png -- 9.72kb -> 6.99kb (28.08%)
/website/static/images/languages/graphql-128px.png -- 8.10kb -> 5.85kb (27.71%)
/docs/assets/youtube-cover/javascript-code-formatting-by-christopher-chedeau-on-react-london-2017.png -- 137.75kb -> 100.08kb (27.34%)
/website/static/images/users/codemix-200x100.png -- 3.82kb -> 2.87kb (24.92%)
/website/static/images/users/m6web-200x100.png -- 21.61kb -> 16.69kb (22.78%)
/website/static/images/users/yelp-200x100.png -- 10.59kb -> 8.23kb (22.35%)
/website/static/images/users/react-200x100.png -- 6.72kb -> 5.23kb (22.13%)
/website/static/images/users/babel-200x100.png -- 15.44kb -> 12.08kb (21.76%)
/website/static/images/users/freelancer-200x100.png -- 5.86kb -> 4.74kb (19.08%)
/website/static/images/users/ideati-200x100.png -- 4.05kb -> 3.29kb (18.62%)
/website/static/images/users/yarn-200x100.png -- 5.75kb -> 4.71kb (18.07%)
/website/static/images/users/talkable-200x100.png -- 3.07kb -> 2.56kb (16.63%)
/website/static/images/users/webpack-200x100.png -- 5.13kb -> 4.44kb (13.49%)
/website/static/images/users/escrow-200x100.png -- 7.47kb -> 6.48kb (13.25%)
/website/static/images/users/moonmail-200x100.png -- 5.69kb -> 4.96kb (12.87%)
/website/static/images/users/jest-200x100.png -- 3.26kb -> 2.84kb (12.86%)
/website/static/images/editors/vim-128px.png -- 13.85kb -> 12.16kb (12.19%)
/website/static/images/users/nhl-200x100.png -- 11.18kb -> 9.85kb (11.92%)
/website/static/images/editors/emacs-128px.png -- 21.24kb -> 18.90kb (11.03%)
/website/static/images/users/jane-200x100.png -- 4.14kb -> 3.70kb (10.71%)
/website/static/images/users/webflow-200x100.png -- 4.51kb -> 4.08kb (9.49%)
/website/static/images/users/storybook-200x100.png -- 6.04kb -> 5.49kb (9.11%)
/website/static/images/editors/vscode-128px.png -- 14.85kb -> 13.53kb (8.9%)
/website/static/images/editors/sublimetext-128px.png -- 6.83kb -> 6.39kb (6.55%)
/website/static/images/users/zeit-200x100.png -- 0.94kb -> 0.88kb (6.45%)
/website/static/images/users/smooth-code-200x100.png -- 9.16kb -> 8.66kb (5.49%)
/website/static/images/languages/css-128px.png -- 7.21kb -> 6.87kb (4.79%)
/website/static/images/users/rnfirebase-200x100.png -- 8.63kb -> 8.26kb (4.28%)
/website/static/images/editors/espresso-128px.png -- 22.42kb -> 21.78kb (2.84%)
/website/static/images/users/monei-200x100.png -- 5.35kb -> 5.31kb (0.75%)
2018-10-16 15:07:33 -03:00
Vojtech Novak caa7b425b7 Update eslint.md (#5276) 2018-10-16 14:11:14 -03:00
Lucas Duailibe 00004daf84
Break nested TSConditionalType (#5272) 2018-10-15 13:35:37 -03:00
Suchipi 0fa34b2c63 Print nested ternaries differently (#5039) 2018-10-14 12:45:37 -03:00
Jed Fox b61fec6091
Fix <Language showName /> prop type (#5265)
There isn‘t a `boolean` prop type, so this was throwing an error when Netlify built the site.
2018-10-14 08:03:35 -04:00
Lucas Duailibe c7093cb3e4
Add ASI protection for TSNonNullExpression (#5262) 2018-10-13 20:03:51 -03:00
Ika dd4687e7ef
feat(html): whitespace-sensitive formatting (#5168)
- whitespace-sensitive formatting 
  - respect css `display: block`/`white-space: pre` (data from [`html-styles`](https://github.com/marionebl/html-styles))
  - support magic comment (`<!-- display: block -->`)
  - add an option to specify whitespace sensitivity (`--html-whitespace-sensitivity <css|strict|ignore>`)
    - magic comments take precedence
    - (default) `css`: respect default css style (safe in the most cases)
    - `strict`: every node is considered whitespace sensitive (the safest)
    - `ignore`: every node is considered whitespace insensitive (dangerous, the original behavior)
  - inline inline-tags 
- support ie conditional comment (`<!--[if IE]><![endif]-->`)
- indent the script/style content
- no inconsistent output for 2+ attributes
- force break tag if there're multiline attributes
2018-10-13 13:55:38 +08:00
Aquib Master 3369be0ca2 Fix comment issue with try finally (#5252) 2018-10-12 12:48:49 -04:00
Jed Fox 65b2454dd8
Improved object-break heuristic (#5205) 2018-10-12 12:45:30 -04:00
Kevin Gibbons cbcd24a5b2 Correct parentheses for mixed exp/mod (#5243)
Fixes #5238.

cc @duailibe for the [original change](https://github.com/prettier/prettier/pull/4413). I basically undid that PR because it didn't look to me like `shouldFlatten` made sense as the place to introduce the behavior it was going for, but I might have misunderstood something.
2018-10-12 12:33:47 -04:00
Ika 3056c5a5c0
fix(yaml): escape quotes correctly (#5236) 2018-10-11 14:31:18 +08:00
Lucas Duailibe ed6a2d9055
Prevent JSX from breaking a logical expression chain (#5092) 2018-10-10 14:11:37 -03:00
Ika bb5a116b4f
fix(markdown): preserve inline math style (#5220) 2018-10-10 09:46:58 +08:00
Lucas Duailibe b5fd382fe8
Inline the arguments of an arrow function in the body is conditional expression (#5209) 2018-10-08 19:28:58 -03:00
Lucas Duailibe ce952fc8c1
Fix printing of catch clause with a comment (#5202) 2018-10-08 14:18:30 -03:00
Lucas Duailibe 303f344bff
Keep decorators inline if they were written inline (#5188) 2018-10-08 11:00:43 -03:00
Jeremy Kairis 8979b47630 Fix a typo in precommit.md Option 4. (#5196)
* Fix a typo in precommit.md Option 4.

* Remove the a
2018-10-07 07:42:41 -04:00
Ika d9ddbe215e docs: fix linting 2018-10-06 20:20:41 +08:00
Warren Seine 7920e6fdde Add a new `trim` command to trim whitespaces in the current line (#4772) 2018-10-06 20:18:52 +08:00
Mahir Shah 30ec30daa9 Escape Quotes in Glimmer String Literals (#5143) 2018-10-05 22:19:33 +02:00
Jed Fox e9cde7d8d4
Adjust badges on the README (#5189)
* Fix spacing around badges

* Switch the npm downloads badge to weekly

I switched to a weekly statistic since it feels more immediate and “9M/m” is somewhat confusing.
2018-10-05 14:06:53 -04:00
Qiming zhao 6b294affa4 Add coc-prettier (#5191) 2018-10-05 11:41:51 -06:00
Lucas Duailibe 31c92a7237
Fix comment in variable declarator (#5190) 2018-10-05 08:40:16 -03:00
Petter 1244729ad7 Infer via shebang (#5149)
If no file type can be inferred, this attempts to read the first line of a file and extract a shebang, which can be checked against a known list.
2018-10-05 08:47:23 +08:00
Ben Scott ea0954995d Update link to stylelint-prettier (#5186)
It belongs to the prettier organization now
2018-10-03 22:11:36 -04:00
Brian Ng 2283efb437
Fix parens around ternary inside OptionalMemberExpression (#5179) 2018-10-02 20:45:15 -05:00
Brian Ng 5315e6fe7a
Bump babel-related deps (#5180) 2018-10-02 20:44:54 -05:00
Kent C. Dodds b84635f0d0 support script type of text/babel in language-html (#5167) 2018-09-30 12:32:25 +08:00
Simon Lydell f87c82cc4e
Improve glimmer parse errors (#5161)
Instead of showing 80 carets, point out just which line the error was
on, and rely on the original message to point out the "column".

I thought about matching the `----^` in the original message with a
regex and use the length of it as the column number, but unfortunately
the original message does not show the original code (in this example
some whitespace is missing), so it wouldn't work.

Before:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   3 |
```

After:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]   3 |
```
2018-09-30 00:25:45 +02:00
Christopher Chedeau 9910536b58
[unicode] Fix trailing nbsp (#5165)
I don't know why I added all the unicode whitespaces instead of just space and tabs, but it's not only unecessary but also wrong.

Fixes #5077
2018-09-29 15:22:13 -07:00
JSON Deppen 80c22d8e39 Fix broken "strings rationale" link (#5163) 2018-09-29 18:01:49 +02:00
Onur Temizkan cc83a27a3e fix(typescript) Do not add extra semicolon to TSMethodSignature when prettier-ignore is used (#5140) (#5160) 2018-09-29 06:13:17 -04:00
Simon Lydell 87e109f884
Escape not just backticks but `${` as well in graphql tags (#5137)
* Escape not just backticks but `${` as well in graphql tags

Fixes #4974.

* Also escape backslashes correctly in graphql tags
2018-09-29 09:42:44 +02:00
Simon Lydell a459743eb2
Update rationale (#5136)
* Clarify semicolon example

* Add rationale for print width

Fixes #5081.

* Link options and rationale

* Add rationale for comments

Refs. #5121.

* Mention that spaces can be used for alignment for --use-tabs

Refs. #4199.

* Add missing word

* Remove bad `istanbul ignore next` example
2018-09-29 09:41:21 +02:00
Simon Lydell 265d9337f6
Update vim docs (#5131)
* Update "Running Prettier manually in Vim" docs

- Add `--stdin-filepath` for parser inference.
- Reword "if you need a little more control" since it can be argued that
this approach gives you _less_ control than the plugins.
- Add note about error messages.
- Add note about cursor position.

* Clean up vim.md

- Replace the out-of-date vim-prettier information with a link to its
readme. Move vim-prettier to the top as compensation for its reduced
part of the page.
- Remove out-of-date instructions.
- Try to provide roughly the same information about Neoformat and ALE.
- Simplify language and formatting.
2018-09-29 09:40:49 +02:00
Simon Lydell dc590e5e4b
Improve documentation for the parser option (#5129)
- Warn about setting parser at the top level. Refs. #4638.
- Remove top level parser from examples. Instead show the most common
options (I also removed printWidth, since we don't recommend changing
it). Refs. #4638.
- Show how to configure the flow parser for .js files. Refs. #4638.
- Update valid options for the parser option, including links and "since
version".
- Clarify babylon vs flow.
2018-09-29 09:40:19 +02:00