Commit Graph

1522 Commits (master)

Author SHA1 Message Date
Ika 153d2d0570
fix(typescript): stable parens for function type in arrow return type (#5790) 2019-01-22 21:07:10 +08:00
Ika 1061be0702
fix(mdx): correctly recognize inline JSX (#5783) 2019-01-22 12:02:30 +08:00
Ika 2002ce0453
fix(javascript): add necessary parentheses for decorators (#5785) 2019-01-22 00:54:41 +08:00
Simen Bekkhus 565731668f fix: do not format callbacks with arguments as React hooks (#5778)
Ref: https://github.com/prettier/prettier/pull/5608#issuecomment-455860396
2019-01-22 00:26:39 +08:00
Ika 42f7b6025e
fix(javascript): remove unnecessary linebreaks from html templates (#5771) 2019-01-20 11:15:18 +08:00
James Henry ef6386015d fix: update typescript and typescript-estree to latest (#5728) 2019-01-12 11:10:52 +08:00
makepost 94eab666c4 fix(javascript): skip .connect() method when composing fun (#5739) 2019-01-10 12:20:15 -07:00
Jarda Snajdr 5847c168e4 Fix formatting of lists in SCSS property/variable values (#5710) 2019-01-10 00:08:34 +08:00
Phil 30979ed104 typescript: remove unneeded parentheses around type annotation (#5724)
* Remove unnecessary parentheses from annotations

* add test for ts parentheses bug
2019-01-07 09:19:41 -03:00
Ika 63999c74eb
fix(mdx): handle inline html correctly (#5704) 2019-01-03 10:46:11 +08:00
Ika 3de36e3a2b
fix(ng,vue): add parens to avoid unexpected `}}` in interpolations (#5657) 2018-12-30 23:03:42 +08:00
Ika 7c4cebeaa5
feat: add babel-flow (#5685) 2018-12-29 21:35:47 +08:00
Wei-Wei Wu 91c20f7fbe Rename "babylon" with "babel" (#5647) 2018-12-27 21:05:19 +08:00
Ika 65a9d3b8cc
fix(flow,ts): format `/* HTML */` templates (#5658) 2018-12-19 23:00:18 +08:00
lhchavez 911d6c88e5 Fix formatting with --range-start / --range-end (#5632)
This change avoids collapsing an already-formatted range into a single
overlong line when --range-start / --range-end are provided.

Fixes: #4923
2018-12-17 10:59:20 -02:00
Dmitriy Sharshakov aka. sh7dm 6a45924379 fix(printer-postcss): ignore escape \ and escaped / in Less (#5597)
Avoid messing up Less files containing \\/ (escaped /).
Ignore escape \ and escaped / in Less.
2018-12-17 08:28:48 +08:00
Ika cbf06bf388
feat(html): format script with "application/ld+json" (#5642) 2018-12-16 16:21:10 +08:00
Brian Ng 8e612f05a0
Add support for class private methods (#5637) 2018-12-14 09:45:26 -06:00
Ika ffc8482458
fix(vue): tag names are case-sensitive (#5606) 2018-12-13 10:31:48 +08:00
Ika 419559e964
fix(javascript): correct indentation for expression in root template (#5607) 2018-12-12 09:52:23 +08:00
Ika 5e89969a9e test: update snapshots 2018-12-11 16:18:29 +08:00
Ika d97fe0a1e0
feat(html): preserve surrounding linebreaks (#5596) 2018-12-11 12:43:53 +08:00
Jed Fox fa7eafaa6d
Add support for the React `useEffect` hook (#5608)
* Add support for the React `useEffect` hook

* Format

* Format

* [Refactor] remove unnecessary condition

`canHaveTrailingComma` is defined as `I(lastElem && ...)`, which will always be true when `lastElem === null`.

* Use a hacky method to allow the array to break

* Revert "[Refactor] remove unnecessary condition"

This reverts commit 91906ba22438afa0fe5e10c64a1fcf3cfa484ff3.

* Add tests for `React.useEffect` form
2018-12-10 06:09:20 -05:00
Ika 952bc0cc03
fix: get rid of CRLF (#5494) 2018-12-08 18:28:29 +08:00
Lipis 7c1758de86
Update example for *.vue (#5605) 2018-12-07 16:34:26 +01:00
Laurin Quast 9d1fb93e86 feat: add mjml extension to html language (#5505) 2018-12-07 21:01:40 +08:00
Ika cd28c22dbe
feat(html): smart quote for attributes (#5590) 2018-12-05 11:15:09 +08:00
Ika 3cd1d003c0
fix(typescript): do not throw errors on bigint keyword (#5577)
- fix `Error: unknown type: "TSBigIntKeyword"`
- bump typescript to stable version
2018-11-30 10:12:32 +08:00
Ika 2247ce1aab
feat(angular): support interpolation in attributes (#5573) 2018-11-30 09:28:54 +08:00
Ika 28b938da97
feat(html): update angular-html-parser (#5565)
- support [`htm`](https://github.com/developit/htm) (`<${Component}>content<//>`, `<div />`)
- preserve [bogus comments](https://www.w3.org/TR/html5/syntax.html#bogus-comment-state) (`<! ... >`, `<? ... >`)
2018-11-29 11:03:22 +08:00
Ika d124bbaacb test: update snapshots 2018-11-29 10:38:37 +08:00
Ika 1ecd2228b4
fix(vue): group slot-scope correctly (#5563) 2018-11-29 10:09:38 +08:00
Ika 0534735c2f
fix(vue): tweak semicolon for single expression in event bindings (#5519) 2018-11-29 09:28:35 +08:00
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
Ika 05ad885c3c
feat(typescript): support BigInt (#5546) 2018-11-27 16:53:34 +08:00
Ika 3a5bbf5fd2
fix(typescript): do not change `module` into `namespace` and break/hug their body correctly (#5551) 2018-11-26 13:34:35 +08:00
Ika a7528ebea4
fix(ng,vue): do not normalize attribute names (#5549) 2018-11-26 12:09:19 +08:00
Ika 4af3dd4b07
test: improve snapshots (#5521)
- before
  ```
  ${input}${"~".repeat(printWidth)}
  ${output}
  ```
- after
  ```
  ===options===
  ${options}
  ${" ".repeat(printWidth)}| printWidth
  ====input====
  ${input}
  ===output====
  ${output}
  =============
  ```
2018-11-25 16:21:14 +08:00
Ika 66ada24961
feat(angular): do not print colon for ngIf (#5542) 2018-11-25 15:43:40 +08:00
Ika b6a04ab8ba
fix(html-in-js): do not add quotes for interpolation-only attributes (#5544) 2018-11-25 15:04:02 +08:00
Ika c788842fea
fix(javascript): add missing parens for binary in optionalMember (#5543) 2018-11-25 11:42:06 +08:00
Ika ab7f46bf40
feat(yaml): preserve the first document head end marker (#5502) 2018-11-25 10:30:25 +08:00
Ika a50a8e258c
fix(javascript): upgrade @babel/parser to 7.1.6 (#5530) 2018-11-24 21:47:47 +08:00
Ika 7da4ed76ad
fix(html): do not touch comments (#5525) 2018-11-23 21:25:58 +08:00
Ika 228a8b0782
fix(html): do not add extra indent for js template in script (#5527) 2018-11-23 15:20:30 +08:00
Ika cdac9552ef
fix(vue,ng): do not normalize tag names (#5526) 2018-11-23 13:12:43 +08:00
Ika b2eadd234b
fix(vue): preserve custom block (#5458) 2018-11-23 12:33:48 +08:00
Ika 6ee2f464ac
feat(javascript): enable logical assignment (#5489) 2018-11-18 16:38:35 +08:00
Ika 043a937de6
fix(markdown): do not trim content in inline-math (#5485) 2018-11-16 00:17:20 +08:00
Ika 668e049a5e
feat(html): support ie conditional start/end comment (#5470) 2018-11-15 12:35:28 +08:00
Ika 4f63be05e8
fix(html): leading space for leading interpolation in textarea is sensitive (#5468) 2018-11-15 10:34:42 +08:00
Ika c00dcb97b0
fix(html): preserve content for element in `<pre>` correctly (#5473) 2018-11-15 10:34:27 +08:00
Huáng Jùnliàng d86f39cb83 fix(markdown): add more category to CJK regex (#5480)
The following characters should be treated as CJK character

```
3099..309A    ; Hira Kana # Mn   [2] COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK..COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
309B..309C    ; Hira Kana # Sk   [2] KATAKANA-HIRAGANA VOICED SOUND MARK..KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
```

Here is the [playground link](https://deploy-preview-5402--prettier.netlify.com/playground/#N4Igxg9gdgLgprEAuEhqhkFkMhahnYeoZ2EaGdQZoZ1AzBkEyGVczcnco8gHSmcGkGQEwZTB7BkHuGQGQjAdgw9AgAyAHhmGBHhmGAnhkDWDIEH7QJ0OgJIZAG3KB1BlIACANoA3ALpbAz+nLAFhGA-50CaDIGiGQMoMgCwZAEP89A2Qxj3E99NeBIf8BBDHyA8QyAMQyA+gyAMgzCgABygDRBgCFuslyAVgyAkQzJrIDGDGGAQAzMzCAANCAQAA4wAJbQAM7IoACGAE6NEADuAApNCLUo9XoQFQAmRSAARo31YADWcDAAyqWTFVAA5sgwjQCucMUAFjAAtgA2AOq7FfDVi2Bwc90XFXoXAJ7I4NW1xcvVcI0w7RMVgd6sgAGb1I4-YoAK2qAA8AEITaazOb1A5wAAyyzgYIhUJAsLhc2WKyOcAAipsIPA8ZCdiBFo0fo03sDGlNBm0oCNSi0ficJqU3ny4Cy9Ljio04ABHTYVaUA+pAkFIcH04o-A4VdZbBnVUnkqk03Fq-EMmD1UYnIYwXbIABMxQ29QqR1JAGEIAdgW8oNBJSBNj8ACpWnrqgl85YwG2DO3IADsAAYAL6poA) to show that current `prettier` adds redundant whitespaces around the characters.

The testcase text are copied from [半濁点 - Wikipedia](https://ja.wikipedia.org/wiki/%E5%8D%8A%E6%BF%81%E7%82%B9) and [ヴ - Wikipedia](https://ja.wikipedia.org/wiki/%E3%83%B4) respectively.
2018-11-15 00:10:50 +08:00
Ika 5c479cc55f
fix(typescript): do not add invalid semi for construct in interface with prettier-ignore (#5469) 2018-11-14 21:35:37 +08:00
Danny McCormick 18b03a31cc Fix tests for Windows and add Azure Pipelines for cross platform CI (#5410)
* Add azure pipelines

* Add gitattributes

* Updating tests to work on Windows or Unix

* Lint

* Cleaning up

* Fixing names

* Clean up naming

* try to consolidate images

* Clean up

* Add back txt to gitattributes
2018-11-14 07:55:50 -05:00
Ika 57b057cfa2
fix(typescript): inline method decorators should stay inlined (#5444) 2018-11-14 10:13:35 +08:00
Ika 7e72889ac1
fix(javascript): fix locEnd for VariableDeclaration caused by --no-semi (#5434) 2018-11-11 00:26:11 +08:00
Ika 1ce76290c0
fix(vue): do not add invalid semicolon for event attr (#5418) 2018-11-11 00:25:11 +08:00
Ika 6cedf7d5d9
fix(flow,ts): consistent interface and remove unnecessary indent for extends (#5432) 2018-11-11 00:15:18 +08:00
Ika e0f74cb94d
fix(javascript): do not attach to block if it's not behind right func paren (#5435) 2018-11-11 00:10:19 +08:00
Ika 182a92eb28
fix(html): preserve incomplete ie conditional comment (#5429) 2018-11-10 16:44:44 +08:00
Ika 8b1260a770
fix(javascript): inline property decorator should stay inline (part 2) (#5423) 2018-11-10 16:44:33 +08:00
Ika cc6899e5c5
fix(css-in-js): do not duplicate comments (#5416) 2018-11-10 16:43:59 +08:00
Ika d4c248bb0b test: update snapshots 2018-11-10 10:52:08 +08:00
Adrian 6dcc7ed575 fix(javascript): handle createSelector as function composition (#5430)
fixes #5285
2018-11-09 17:55:57 -07:00
Ika 6fafd0a48d
fix(angular): correctly print unary expression with `+` (#5405) 2018-11-10 01:01:18 +08:00
Ika 4e7fca5047
fix(markdown): identify CJK correctly (#5402) 2018-11-10 01:00:58 +08:00
Ika 1bce579f8d
fix(ng|vue): whitespaces between interpolation and text are sensitive (#5396) 2018-11-10 01:00:26 +08:00
Ika de11f69889
fix(html): preserve unterminated ie conditional comments (#5424) 2018-11-09 23:26:59 +08:00
Ika 6f6b634948
fix(html): preserve content for `<template>` with unknown lang (#5388) 2018-11-09 19:19:03 +08:00
Ika 423ddf9abd
fix(angular): add missing parens for pipe in ternary (#5397) 2018-11-09 09:51:54 +08:00
Ika 9acb02997a
feat(html): treat capital element as custom element (#5395)
Custom element: keep it on its own line if both leading/trailing line breaks exist
2018-11-09 09:51:31 +08:00
Ika 0228863a92
feat(html): handle pre with interpolation (#5400) 2018-11-09 09:50:57 +08:00
Ika 32ea48d499
fix(scss): do not throw if node.source undefined (#5394) 2018-11-09 09:48:16 +08:00
Ika 469a831619
fix(mdx): treat jsx codeblock same as in markdown (#5391) 2018-11-09 09:47:05 +08:00
Ika 7f472d72ae
fix(angular): handle parens in ng expression correctly (#5387) 2018-11-09 00:06:16 +08:00
Ika fd8ec95e0a
fix(javascript): do not apply test call formatting to arrow without body (#5366) 2018-11-08 14:00:42 +08:00
Ika 4b51907b87
fix(javascript): inline property decorator should stay inline (#5364)
Fixes the `@action` part in #5360
2018-11-07 17:21:03 +08:00
Ika 8cedb9d25e
fix(markdown): do not keep increasing backslashes for dollar sign (#5358) 2018-11-07 10:06:57 +08:00
Brian Ng e882452c54 Bump @babel/parser (#5356)
Follows #5304 with flow inexact support in @babel/parser!
2018-11-07 08:42:11 +08:00
Ika 40ac85125a
fix(html-in-js): do not break empty content (#5355) 2018-11-07 08:32:26 +08:00
Ika a4e8aaf7a1
fix(jsx): do not move trailing char to the next line as leading char (#5354) 2018-11-07 07:41:34 +08:00
Ika 6a54e21c12
fix(css-in-js): do not remove semicolon (#5353) 2018-11-07 00:19:42 +08:00
Alexander Kachkaev b87fe4cf22 Add option to enforce certain line endings (#5327) 2018-11-06 22:47:13 +08:00
Ika 40f46740f6
fix(jsx): consistent quotes in JSX expression (#5349) 2018-11-06 15:38:50 +08:00
Ika b6691ba615
fix(javascript): no regression for jsx in arrow function in jsx (#5343) 2018-11-06 15:38:30 +08:00
Ika 02f9802119
fix(javascript): no regression for ternary#test alignment (#5333) 2018-11-05 17:07:57 +08:00
Stefan Mirea e17512adcd Add an option to print single quotes in JSX (#4798)
* feat(option-singleQuote-jsx): Added jsSingleQuote

* feat(option-singleQuote-jsx): Refactored to use a simple jsxSingleQuote flag

* feat(option-singleQuote-jsx): Fixed borked rebase

* feat(option-singleQuote-jsx): Updated snapshots

* feat(option-singleQuote-jsx): Resolved pending comments

* feat(option-singleQuote-jsx): Removed assert

* Fixed merge conflicts

* Updated snapshots after merge conflicts
2018-11-04 16:36:00 -05:00
Ika 5e8a4a115a
feat: support HTML/Vue/Angular (#5259) 2018-11-04 23:03:07 +08:00
Simon Lydell 275b0543c8
Never put spaces to the right of stars in indentable block comments (#5330)
Fixes #5323. Previously we added space after `/*` _on the first line
only,_ but the intent is to only fix the indentation of comments, not
changing their "contents". Besides, this was inconsistent with the
handling of every following line. Finally, it broke `/*!` comments which
some minifiers look for to know which (license) comments to keep.

People can use https://eslint.org/docs/rules/spaced-comment to enforce
when to start comments with spaces.
2018-11-03 20:53:24 +01:00
Onur Temizkan f6d8be881c fix(css-in-js) Keep newlines in CSS-in-JS Templates (Fixes: #5147) (#5240)
* fix(css-in-js) Keep newlines in CSS-in-JS Templates (Fixes: #5147)

* Add more tests

* Do not add semicolon when CSS prop is a template variable

* Fix deletion of original semicolon

* Prettify long line
2018-11-01 21:58:16 +02:00
Jaiden Gerig 0799280429 Fixed unstable comment between function declaration and block statement (#5250) 2018-11-01 21:55:33 +02: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
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
Lucas Duailibe 62e4654e60
Respect original text decorator order (#5207) 2018-10-17 14:14:59 -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
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
Mahir Shah 30ec30daa9 Escape Quotes in Glimmer String Literals (#5143) 2018-10-05 22:19:33 +02:00
Lucas Duailibe 31c92a7237
Fix comment in variable declarator (#5190) 2018-10-05 08:40:16 -03:00
Brian Ng 2283efb437
Fix parens around ternary inside OptionalMemberExpression (#5179) 2018-10-02 20:45:15 -05:00
Kent C. Dodds b84635f0d0 support script type of text/babel in language-html (#5167) 2018-09-30 12:32:25 +08: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
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
Toru Kobayashi 3e05f210bb fix(js): quote property name as es5 compatible (#5157) 2018-09-28 13:51:34 -03:00
Onur Temizkan d7e96adac0 fix(js) Break args when second arg is a ternary (#5046) (#5151) 2018-09-27 16:50:33 -04:00
Ika 07abf0588e
fix(html): non-HTML attributes are considered case-sensitive (#5135) 2018-09-27 20:18:00 +08:00
James Henry 81cf08118e
Drop-in replacement: typescript-estree for typescript-eslint-parser (#5139) 2018-09-25 15:44:21 -04:00
Ika 51954daa74
fix(html): do not format unknown script (#5132)
- do not format unknown script
- do not normalize spaces in script tags
2018-09-23 08:36:54 +08:00
Ika 13147facc5
feat(html): switch to htmlparser2 (#5127)
- switch to [`htmlparser2`](https://github.com/fb55/htmlparser2)
  - no need to fork
  - won't generate pseudo nodes ([`parse5` will](https://github.com/prettier/prettier/issues/5098#issuecomment-423055181))
  - should be [faster](https://github.com/fb55/htmlparser2#performance)
- support custom self-closing tags
- support HTML entities
- remove extra trailing newline for `<template>`
- distinguish empty/empty-string attributes (`<tag x>`/`<tag x="">`)
- rename `--parser parse5` with `--parser html`
- enable `html` since 1.15, which means it's enabled by default if you install the dev version from GitHub after this PR merged.
2018-09-22 21:53:38 +08:00
Ika 0cbacd3156
fix(markdown): trailing spaces after front matters are allowed (#5107)
```md
---···· <--- allowed
yaml
---···· <--- allowed

markdown
```
2018-09-21 19:51:03 +08:00
Ika 27bf64f6ce
feat(html): self-closing for void tags (#5116)
XHTML compatibility.
2018-09-20 00:04:43 +08:00
Ika 4a084c82a1
fix(html): no need to strip newline for text in script-like tag (#5111)
The issue here is that the `stripTrailingHardline` does not work for js/ts, I fixed it and then I realized that we always print trailing newline in every language, so there's no need to strip newline for text in script-like tag.
2018-09-20 00:03:50 +08:00
Ika 8ddff0787a
feat(html): support front matter (#5110)
- format yaml front matter
- preserve toml front matter
2018-09-19 22:10:41 +08:00
Ika 02fcea06fd
fix(html): preserve case-sensitive attributes (#5109)
Attributes in non-HTML tags are considered case-sensitive.
2018-09-19 21:36:37 +08:00
Ika 00ed49fad9
fix(html): preserve case-sensitive tag names (#5101) 2018-09-19 12:53:38 +08:00
Ika 5bcd4424fa
fix(css): no wrong loc info caused by front matter (#5103)
Replace front matter with whitespaces to maintain the loc info.
2018-09-19 09:18:50 +08:00
Ika 79d510cf31
fix(html): exclude comments from fragment detection (#5100)
Context: https://github.com/prettier/prettier/pull/4753#discussion_r200848784
2018-09-17 21:38:06 +08:00
Ika 5cd367e502
fix(typescript): no invalid parens for destructuring with default value (#5096) 2018-09-15 21:45:43 +08:00
Evilebot Tnawi 8b0bdf52be [WIP] feat: html support (#4753)
* feat: html support

* fix: support empty lines between children

* refactor: isScriptTagNode util

* refactor: rename `glimmer` and `handlebars` tests

* fix don't add newline after `directive` node

* fix: support `pre` tag

* fix: don't trim comments content

* fix: `script` and `style` tags output

* feat: indent `head` and `body` inside `html`

* fix: better handle quotes around attribute value

* feat: better handle embed

* tests: svg into html

* fix: better handle boolean and empty attributes

* chore(deps): update `parse5` to latest version

* fix: better handle empty attribute

* tests: fix

* fix: extra newline in multiline node

* fix: print `pre` and `textarea` in right way

* tests: xhtml doctype

* fix: use `>` instead `/>`

* tests: case

* refactor: remove `toLowerCase()`

* feat: support `prettier-ignore`

* tests: empty `script` and `style` tags

* fix: clean

* tests: refactor and more
2018-09-13 07:06:49 -06:00
Jed Fox 59720392c3
Add support for timeouts passed as integers to test functions (#5085)
* Add support for timeouts passed as integers to test functions

* ;
2018-09-13 06:08:47 -04:00
Ika f7a6625d84
fix(typescript): no-semi for class props with modifiers (#5083) 2018-09-13 11:14:21 +08:00
Lucas Duailibe b020a5606f
Keep simple JSXOpeningTag's unbroken (#5078) 2018-09-11 11:15:50 -03:00
Ika 9ca10a378f
fix(typescript): add parens for complex nodes in ClassExpression (#5074) 2018-09-10 08:18:30 +08:00
Ika 4d488e8b81
fix: no false positive for arrow function in jsx expression (#5063) 2018-09-07 09:39:59 +08:00
Lucas Duailibe 87376f93f3
Inline Generics with a single identifier (#5066) 2018-09-06 14:44:21 -03:00
Ika 461e6035c1
fix(typescript): preserve necessary parens for TSOptionalType (#5056) 2018-09-06 09:04:37 +08:00
Ika a1545a835a
feat(markdown): preserve math (#5050)
- preserve inlineMath (`$inline$`) and blockMath:

  ```md
  $$
  block
  $$
  ```
- side effect: `$` always needs to be escaped.
2018-09-05 21:07:37 +08:00
Eric Sakmar 6288704c41 format jest calls like regular calls (#5011) 2018-09-03 10:15:23 -03:00
Yulia Galuzo 0c7c1bfde4 fix: splitting jsx text correctly (#5006)
Fixes: #4941
2018-09-02 19:59:28 +02:00
Ika 91206891cd
fix(markdown): do not add whitespaces between Latin and Hangul (#5040)
Based on https://github.com/prettier/prettier/issues/5028#issuecomment-417825085, it seems Korean text uses conventional space so we're not going to add whitespaces between Latin and Hangul.
2018-09-02 16:20:22 +08:00
Felix Wu e86f08555a Bugfix/ Don't inline pipeline operator with leading ownline comment (#5015)
* don't inline pipeline operator with leading ownline comment

* Add tests for comments surrounded with binary expressions

* Add babylon test for ownlinecomment with pipeline operator
2018-09-01 18:38:19 -04:00
Ika db2bc3636d
fix(yaml): update parsers (#5027)
- upgrade to `yaml@1.0.0-rc.8` and `yaml-unist-parser@1.0.0-rc.4`
- refactor some logic since the AST has slightly changed (ikatyang/yaml-unist-parser#82)
- unmatched aliases are now errors since it may introduce invalid AST from `yaml`
- rewrite the document separator (`...`/`---`) logic, this fixes some cases where it can use `---` but we printed `...`
- removed some unnecessary duplicate trailing newline
- trailing comments on `document` (`... #comment`) and `documentHead` (`--- #comment`) are preserved (i.e. they won't be moved somewhere)
2018-09-01 20:04:37 +08:00
Ika 165742014a
fix(markdown): preserve leading/trailing newlines in fenced code block (#5038) 2018-09-01 13:35:29 +08:00