* 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
* 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
- 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)
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
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.
* 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
* 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
* 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
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.
- 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`
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.
* 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.
* Add a single test suite for blank files in all parsers
The parsers that don’t yet support blank files have been filtered out of the list until they do.
* Don’t directly `require()` Prettier
* Update `require`
* Add missing Babylon parser
* Update snapshots
We landed a change that added a new `InterpreterDirective` AST node type for hashbangs, and no longer add it as a comment/leadingComment.
Ref: https://github.com/babel/babel/pull/7928
I mimicked what we do in `@babel/generator` here, since I found it better than trying to add comments to the ast in `parser-include-shebang.js`). Definitely open to a better/cleaner option though!
Note: I'll follow this up with enabling tests for https://github.com/prettier/prettier/pull/4543 and https://github.com/prettier/prettier/pull/4540 once they land too.
* Support new node types for optionals
* Update babylon
* Fix decorator tests
* fix manual errors
* Update flow
* pretty print
* enable option for flow to support ??
* fix AST_COMPARE=1
* fix lint and explicitly test 1_2_3 syntax for flow
* Don't default parser to babylon
* Different default values according to version
* Fix error logging
* Add tests specifically for parser inference
* Add another test case
* Add API test
* Break link definitions onto multiple lines when needed
* Simplify the conditional for breaking the title
* Don’t print the title if it’s blank
* Revert "Don’t print the title if it’s blank"
This reverts commit 2a8d0dd9995a2e5ab8e6d888c07b88dda058637f.
* Add another test
* Fix title printing
* Second time’s the charm
* Third time’s the charm?
* Fix snapshot
* Prettify
* Don’t break unless `proseWrap` is `always`
* Test `proseWrap: never` on link references
* Added support for the graph ql comment tag
As described in the issue https://github.com/prettier/prettier/issues/4360
Prettier still adds a space inbetween the comment tag and the template literal.
* Added comment explaining the random spaces around GraphQL
* Fixed failing AST_COMPARE tests
* Add tests showing existing behavior of various TS casts.
* Improve formatting of TS casts with generics and unions.
By adding a soft break between the cast and the expression. Also
includes wrapping parentheses for clarity as suggested in #4171.
Avoids changing behavior at all though if casting an array or object
literal because those already have good behavior where the array or
object literal breaks before the cast does so including them would just
result in a pointless extra layer of parentheses that would add no
clarity.
* Update tests in prepation for updating long cast format.
* Update so nested breaks inside type cast are indented.
* Add tests where expression being cast is too long itself.
* Update cast formatting to only sometimes break after cast.
Specifically it will break after the cast if that makes the cast itself
fit on a single line. If the cast itself won't fit on a single line then
the expression being cast will be placed directly after the `>` at the
end of the cast.
* Add heuristic to format functional composition more nicely
* Regex -> array
* Use object instead of array for faster lookup
* Remove empty lines
* Add redux connect
Also add comments for libraries
* handle cusor position relative to comments correctly
* use more robust method of cursor offset tracking
* add support for cursorOffset with rangeStart/End
* add tests for cursorOffset
* use old JS syntax for node4
* add another cursor offset test case
* remove trailing whitespace in cursor tests
* fix null findNodeAtOffset handling
* remove dead code
* add more test cases
* use indexOf for node4
* revert comments.js
* add more comment tests
* change tests infra
* Fix AST_COMPARE
* move CURSOR to top level of file
* mutate result
* use es6 property shorthand
* simplify diff offset calculation
* put remaining test cases in individual files
* Fix: Always preserve frontmatter, remove dependency
* Move correct test to correct filename
* Add test for malformed frontmatter, finetune regex
* Use other malformed test case
* Update yarn.lock
* fix(glimmer): preserve leading/trailing spaces in text nodes underneath attribute nodes when next to mustache statements.
* fix(glimmer): format printer-glimmer.js
* fix(glimmer): lint fix
* fix(glimmer): removed decomposition assignments to be compatible with Node 4
* fix(glimmer): Array.includes() -> indexOf() for Node 4