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.
* 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
* 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
- 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
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.
- 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.
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.