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
Ika
4ce28d3ef4
fix(markdown): inline footnote def if there's only one 1-line paragraph ( #5025 )
2018-09-01 13:14:22 +08:00
Ika
669282e32a
fix(markdown): stably print lists in front of whitespace-only trailing newline ( #5024 )
2018-09-01 12:14:53 +08:00
Ika
32390cd6a3
fix(vue): do not pass `<script src>` into multiparser ( #5031 )
2018-08-31 09:28:55 +08:00
Eric Sakmar
93e8b15311
verify the precedingNode type when handling import declaration comments ( #5016 )
2018-08-27 20:02:40 -06:00
Felix Wu
8779937a07
Bugfix/ Leave Dangle Comments in NewExpression ( #5017 )
...
```js
new Thing(/* comment */)
```
now stays the same instead of being formatted into
```js
new Thing /* comment */()
```
2018-08-27 09:23:14 +08:00
Malcolm Groves
d480858f01
Fix ternary format in function call ( #4368 )
...
* Fix ternary format in fn call
* Formatted to align with linter
* Update jsfmt.spec.js.snap
* Update jsfmt.spec.js.snap
* test: remove obsolete snapshot
2018-08-15 13:29:04 -04:00
Ika
1790211f76
feat: support MDX ( #4975 )
...
* feat: support MDX
* refactor: flip condition
2018-08-13 22:23:09 +08:00
TitanSnow
2de54dc4d8
remove redundant ASI protection for BindExpression ( #4970 )
2018-08-13 22:17:28 +08:00
Ika
6ba6138d09
feat(yaml): prefer implicit key for empty value ( #4972 )
...
* feat(yaml): prefer implicit key for empty value
* fix: prefer `?` for `!!set`
* refactor
2018-08-12 13:38:14 +08:00
TitanSnow
b0a33b7326
fix #4963 : parens are incorrectly stripped in BindExpression ( #4964 )
...
* fix #4963
* lint code
* fix more incorrectly paren stripping
* always need parens when UnaryExpression in BindExpression
* lint code
2018-08-09 14:44:13 -03:00
Ika
4d2f224919
fix(javascript): add parens for unary in bind ( #4950 )
...
* test: add tests
* fix(javascript): add parens for unary in bind
2018-08-08 23:48:12 +08:00
Adrian Leonhard
c83d5b15e7
Fix #4886 and add test. ( #4954 )
2018-08-08 09:24:25 -06:00
Brian Ng
1391891ef6
Print ObjectTypeInternalSlot with both flow/babel parsers ( #4869 )
...
* Print ObjectTypeInternalSlot with both flow/babel parsers
* chore: update to flow-parser@0.78.0
* test: update snapshot
2018-08-08 09:21:39 -06:00
Suchipi
418a04bf2b
Revert this/super blacklist for function composition heuristic ( #4936 )
2018-08-08 09:18:46 -06:00
Ika
308863e061
fix(typescript): no invalid output for ImportType in TypeReference ( #4939 )
2018-08-07 18:53:11 +08:00
Ika
42ba638f37
fix(yaml): update parser ( #4931 )
...
* test: add tests
* fix(yaml): update parser
2018-08-03 15:10:26 +08:00
Christopher Chedeau
3b3240bdb8
[assignment] proper group ( #4932 )
...
If you have
```js
a = b
```
we used to do
```js
group[a = b]
```
which works most of the time but has the unfortunate side effect that if the left part breaks, we're going to break the `=` as well. So you get
```js
{
a
} = \n
b
```
What this PR does it to add a group
```js
group[a group[= b]]
```
so that if the right hand side fits in one line, it should stay that way.
Note that there's a change with a comment being move but I think that it's fine. If I remember correctly, this test was to make sure that we didn't print invalid code, not that it had to be respected (that comment position is not something we really want to support in the first place).
Fixes #4645
2018-08-02 20:26:31 -07:00
Brian Ng
1597578b05
Bump babel-parser ( #4910 )
2018-08-02 22:19:21 -05:00
Ika
b6077e175e
fix(yaml): end comment in nested mapping ( #4918 )
...
* test: add tests
* fix(yaml): end comment in nested mapping
2018-08-02 22:38:16 +08:00
Ika
10df246772
feat(yaml): do not put singleline values on a separate line from the key ( #4916 )
...
Only apply to `alias` and `plain`/`quoteSingle`/`quoteDouble` with
- no backslash newline
- or no literal newline and `proseWrap: preserve`
- or no newline and `proseWrap: never`
- or no whitespace and `proseWrap: always`
in mapping items with implicit key, otherwise it's impossible to do prose wrapping.
2018-08-02 00:15:33 +08:00
Paul Chavard
783923a81b
fix(glimmer): preserve empty text attributes ( #4897 )
2018-08-01 12:45:36 -03:00
Ika
d83ca5a6c6
fix(yaml): prefer dash as document separator ( #4921 )
...
* test: add tests
* fix(yaml): prefer dash as document separator
2018-08-01 14:10:06 +10:00
Paul Chavard
0571b2b884
fix(glimmer): treat glimmer components as self closing tags ( #4900 )
2018-07-27 06:49:13 -04:00
Ika
556fb3e646
feat(markdown): only align lists if they're already aligned ( #4893 )
...
* feat(markdown): only align lists if they're already aligned
* fix: handle single item with multiple leading spaces
* fix: empty items are considered not aligned
2018-07-27 09:48:09 +08:00
Ika
1c33224117
fix(typescript): support jsx spread child ( #4885 )
...
* fix(typescript): support jsx spread child
* chore(deps): update to use typescript-eslint-parser@17.0.0
2018-07-26 22:13:32 +08:00
Paul Chavard
65d65a5c13
fix(glimmer): better formatting of boolean attributes (and also ...attributes) ( #4891 )
2018-07-26 09:50:45 -03:00
Paul Chavard
505e08292c
fix(glimmer): add softline in nested block statements ( #4896 )
2018-07-26 09:49:50 -03:00
Paul Chavard
ca8e049126
fix(glimmer): remove extra space from sub-expressions without params ( #4890 )
2018-07-24 19:50:30 -03:00
Paul Chavard
5d254ce310
fix(glimmer): do not strip block params on <Component> ( #4889 )
2018-07-24 19:07:49 -03:00
Ika
02f64af6e3
fix(vue): no error on range format ( #4868 )
2018-07-22 15:58:29 +08:00
Suchipi
3bfaf6626c
Never inline decorators, unless they're lone parameter decorators ( #4830 )
...
Fixes #2613 .
2018-07-20 13:48:37 -06:00
Ika
1a2c4e663e
chore: use pre-release version number on master ( #4855 )
...
* chore: use pre-release version number on master
* docs: tweak comment
2018-07-18 09:38:26 +08:00
Ika
cb7fe00863
fix(yaml): support end comments ( #4854 )
2018-07-18 09:37:53 +08:00
Ika
ed0ecdad18
fix(json): do not put values on a separate line from the key ( #4852 )
...
* test: add tests
* fix(json): do not put values on a separate line from the key
2018-07-17 18:08:59 -03:00
Eugene Datsky
03ee86ea80
Blacklist this in functional composition heuristics ( #4836 )
2018-07-12 11:58:57 -03:00
Ika
cd16ff27d7
fix(markdown): preserve entity for surrogate pair ( #4832 )
2018-07-12 21:42:39 +08:00
Ika
da91fb2f46
fix(javascript): allow top level super and await ( #4823 )
2018-07-11 13:18:20 +08:00
Ika
2271992446
feat(json): add jsonc to aliases and use it to find parser in markdown embed ( #4734 )
2018-07-07 20:46:34 +08:00
Ika
0df2199688
fix(grahpql): linebreak in non-block stringValue ( #4808 )
2018-07-05 00:14:09 +08:00
Ika
432c9d7d04
feat(yaml): support proseWrap ( #4742 )
...
- support `proseWrap` in `yaml`
- move `proseWrap` to `commonOptions`
- update to `yaml@1.0.0-rc.4` and `yaml-unist-parser@1.0.0-rc.1`
2018-07-04 00:28:47 +08:00
Simen Bekkhus
51b7c02e12
Upgrade jest to 22 ( #4782 )
...
* chore: upgrade Jest
* chore: update snapshots
* chore: lock down babel dependency using invalid syntax
* 2 args to test.skip
* use jest 22 for now
* Revert "2 args to test.skip"
This reverts commit 691fdc3f99e320f2303958f2b503f7b4c93fa455.
* remove snapshot name from matcher
* fix standalone tests skips
2018-07-03 03:06:29 -03:00
Ika
99c4e41fa1
feat: format yaml front matter ( #4773 )
...
* refactor: front-matter
* feat: format yaml front matter
2018-07-03 09:54:40 +08:00
Alexander Kachkaev
a05fd118be
Do not require space after markdown block language name ( #4783 )
...
https://github.com/prettier/prettier/pull/4153 made it possible to detect fenced code block language when it is followed by arguments (e.g. ` ```js {something=something} `). This PR makes it also possible to detect language in cases cases like ` ```js{something=something} ` (no space).
The reason for this change is that Atom highlights code blocks regardless of a space after the language name, which makes users wonder why the correctly detected code block is not being formatted:
<img width="324" alt="screen shot 2018-06-28 at 22 08 13" src="https://user-images.githubusercontent.com/608862/42060780-db11f5b6-7b1f-11e8-9f43-fe91843f7d89.png ">
PR background: https://github.com/prettier/prettier/pull/4153#issuecomment-401174999
2018-07-02 08:22:56 +08:00
Ika
61d5eeadd3
fix(javascript): add parens for await in bind ( #4778 )
2018-06-30 23:15:45 +08:00
Ika
50d242d085
feat(typescript): support TSOptionalType and TSRestType ( #4757 )
...
Ref: Microsoft/TypeScript#24897
2018-06-30 09:10:56 +08:00
Ika
e10c31a333
fix(typescript): update typescript-eslint-parser ( #4762 )
2018-06-29 19:27:21 +08:00
Ika
b67fa907bd
fix(markdown): preserve email autolink ( #4740 )
...
```diff
<hello@example.com>
<mailto:hello@example.com>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-<mailto:hello@example.com>
+<hello@example.com>
<mailto:hello@example.com>
```
2018-06-27 08:36:51 +08:00
Karl O'Keeffe
7a3ac3a693
Handle JSX whitespace separately from fbt whitespace ( #4717 )
...
* Hande JSX whitespace separately from fbt whitespace
* Extra test cases
* Further tweak to JSX handling
* Possible improvement of single character text
* More tests
* Pull out separator code
* More tests for fbt
2018-06-25 19:11:40 +01:00
Ika
f51acf22fe
feat(vue): support pragma ( #4713 )
2018-06-25 10:44:00 +08:00
Ika
c38e6af301
fix(yaml): add missing `since` field ( #4739 )
2018-06-23 17:04:47 +08:00
Suchipi
cb5e1db4a5
Revert "Ternary Operators in JSX Expression Containers ( #4731 )" ( #4736 )
...
This reverts commit 12046cd01b
.
2018-06-22 10:32:38 -06:00
tyrerexus
12046cd01b
Ternary Operators in JSX Expression Containers ( #4731 )
...
This pull request aims to fix the issue of excessive nesting brought up in the following comment: https://github.com/prettier/prettier/issues/737#issuecomment-392541493
This "fix" is very simple. It adds a new possible way to activate JSX mode for ternary operators. If the first non-conditional parent of the expression is a JSX expression container, then JSX mode gets activated.
This branch also contains a test case for said scenario.
2018-06-22 10:30:53 -06:00
David Gomes
9e0b1223cd
Update postcss-scss parser version to 1.0.6 (with test for it). ( #4733 )
2018-06-22 13:42:15 +03:00
Rubén Norte
cbef0105e9
Upgrade flow-parser to 0.75.0 ( #4727 )
...
* Upgrade flow-parser to 0.75.0
* Added failing test for optional catch binding and flow-parser@0.74.0
2018-06-21 10:50:54 -07:00
Ika
dcf44ffbdc
feat: support YAML ( #4563 )
...
* 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
2018-06-21 10:29:42 +08:00
Ika
b99de9811b
feat(graphql): support pragma ( #4699 )
2018-06-17 14:04:48 +08:00
Ika
4109abf4dd
feat(javascript): support BigIntLiteral ( #4697 )
2018-06-16 00:20:04 +08:00
Evilebot Tnawi
03a2002348
fix: newline between front-matter and comment ( #4701 )
2018-06-15 16:27:41 +03:00
Vojtěch Štěpančík
56af3d621d
Add support for parsing babylons throwExpressions ( #4695 )
2018-06-14 21:35:39 -03:00
Ika
f6890bd071
feat(css): support pragma ( #4688 )
2018-06-14 09:51:18 +08:00
Ika
5646573ad7
fix(javascript): preserve parens for type casting for sub-item ( #4648 )
2018-06-11 19:50:53 +08:00
Lynn Smeria
61d35dd636
fix(typescript): preserve type parameters of import-types ( #4656 ) ( #4662 )
2018-06-11 11:29:10 +10:00
Ika
98bfd03d93
feat(typescript): support unknown type ( #4625 )
2018-06-10 00:12:30 +08:00
Lucas Duailibe
d013983d8a
Always expand first argument if the second argument is also a call expression ( #4657 )
2018-06-08 15:16:12 -03:00
Lucas Duailibe
cb1c52ad08
Break JSX in arrow functions in JSX expressions ( #4601 )
2018-06-08 15:15:50 -03:00
Ika
35a42bef24
fix(markdown): better handling for trailing spaces ( #4593 )
...
- preserve trailing spaces in html, excluding html comment
- `doc-printer` is now unrelated to `options.parser`
- fix some cases that two trailing spaces are mis-considered as `break`
2018-06-08 00:20:25 +08:00
Aakansha Doshi
8ec5432768
Fix empty file error in json and graphql ( #4553 )
...
* Fix empty file error in json and graphql
* fix AST_COMPARE=1 issue
* use tests/empty
* revert
* fix lint
2018-06-06 10:41:12 -03:00
Ika
f27f6c525b
fix(typescript): preserve decorator on interface ( #4632 )
2018-06-05 00:08:24 +08:00
Lucas Duailibe
a4da6e6c8e
Inline _ or $ in the root of a method chain ( #4621 )
2018-06-01 12:51:06 -03:00
Ika
b55997eb3d
fix(multiparser): no additional trailing newline for graphql in js ( #4616 )
...
Fixes #4615
The root cause is the output doc from graphql printer does not match the desired input from `stripTrailingHardline`.
a9b21a01e2/src/doc/doc-utils.js (L167-L180)
2018-06-01 00:38:39 +08:00
Ika
e74e6565b4
fix(markdown): respect blank line between block htmls ( #4609 )
...
Fixes #4605
The AST here is actually two `html`s and it did follow the [CommonMark spec](https://spec.commonmark.org/0.28/#html-blocks ), so I ended up with respecting the blank line between block `html`s.
2018-06-01 00:33:37 +08:00
Evilebot Tnawi
9387e9d833
fix: comment type for scss ( #4598 )
2018-05-30 23:22:18 +03:00
Ika
8abbc5d4b0
fix(javascript): regression for `hasOwnProperty` ( #4603 )
2018-05-31 00:39:39 +08:00
Evilebot Tnawi
3d60871458
fix: output color adjusters ( #4494 )
2018-05-29 15:24:38 +03:00
Lucas Duailibe
b8ded70848
Handle comments in assignments before template literals ( #4580 )
...
Closes #4560
2018-05-29 00:08:18 +10:00
Lucas Duailibe
a6db391556
Short rule should only apply to the first identifier ( #4575 )
2018-05-27 21:52:42 -03:00
Kevin Donnelly
16a84e88d6
Improve format when passing ts arrow function with return type as an argument ( #4228 )
...
* Add various tests for ts type annotated function properties.
* Improve format when passing ts arrow function with return type
* Add test for case from #2581 .
2018-05-27 20:39:08 -03:00