Commit Graph
100 Commits
Author SHA1 Message Date
Ika fa40f2ddd3 docs(blog): 1.15 release (#5296) 2018-11-07 09:09:04 +08:00
Ika 4559a774bb Release 1.15.0 2018-11-07 09:07:53 +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
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 e022abc9b8 chore(playground): add a temporary workaround for parser-vue (#5347)
Temporary workaround
2018-11-05 22:11:59 +08:00
Ika 02f9802119 fix(javascript): no regression for ternary#test alignment (#5333) 2018-11-05 17:07:57 +08:00
Ika f6a95dd2e0 chore(deps): replace parse-srcset with the gh commit one
to avoid potential changes
2018-11-04 23:19:41 +08:00
Ika 5e8a4a115a feat: support HTML/Vue/Angular (#5259) 2018-11-04 23:03:07 +08:00
Ika 0878a6a3e7 fix(less): remove CRs from inline comments (#5334)
The issue here is that less parser somehow included CRs in `comment.raws.content`, but it was hidden by the wrong trailing space elimination previously, which was fixed by #5165.

We already have such tests but it's not reproducible in AppVeyor since they use LF ([`core.autocrlf=input`](https://stackoverflow.com/a/20653073)).
2018-11-04 11:36:14 +08:00
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
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
Ika 3056c5a5c0 fix(yaml): escape quotes correctly (#5236) 2018-10-11 14:31:18 +08:00
Ika bb5a116b4f fix(markdown): preserve inline math style (#5220) 2018-10-10 09:46:58 +08:00
Ika d9ddbe215e docs: fix linting 2018-10-06 20:20:41 +08:00
Ika 07abf0588e fix(html): non-HTML attributes are considered case-sensitive (#5135) 2018-09-27 20:18:00 +08: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 ebedd5b74a refactor(html): simplify/extract code (#5112)
- extract utilities
- use built-in hasPrettierIgnore
- simplify some functions
- remove dead code
2018-09-19 23:07:27 +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 8e88f52225 chore: bump Prettier dependency to 1.14.3 2018-09-19 21:02:43 +08:00
Ika 835f4c05b0 chore: copy LICENSE to dist (#5114) 2018-09-19 20:43:26 +08:00
Ika 00ed49fad9 fix(html): preserve case-sensitive tag names (#5101) 2018-09-19 12:53:38 +08:00
Ika 79f4251e26 chore: enable html on preview playground (#5105) 2018-09-19 09:19:18 +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 a5cecbdfee docs(html): add reference for boolean attributes 2018-09-15 22:02:36 +08:00
Ika 5cd367e502 fix(typescript): no invalid parens for destructuring with default value (#5096) 2018-09-15 21:45:43 +08:00
Ika f7a6625d84 fix(typescript): no-semi for class props with modifiers (#5083) 2018-09-13 11:14:21 +08:00
Ika 9ca10a378f fix(typescript): add parens for complex nodes in ClassExpression (#5074) 2018-09-10 08:18:30 +08:00
Ika 4ff0f26d3e refactor: move cli leven suggestion to options-normalizer (#5057)
Option-related processing should be done in `options-normalizer`.

- unknown flag suggestions are colored
  ![image](https://user-images.githubusercontent.com/8341033/45103027-866c7900-b161-11e8-8ee3-6467a9ca0090.png)
- unknown flags with no suggestion are now errors:
  ```
  $ bin/prettier.js --help noseminosemi
  [error] Invalid `--help` value. Expected `a flag`, but received `"noseminosemi"`.
  ```
2018-09-08 07:40:09 +08:00
Ika 4d488e8b81 fix: no false positive for arrow function in jsx expression (#5063) 2018-09-07 09:39:59 +08:00
Ika 1965b74e61 refactor: move index.js and standalone.js to src (#5054)
There're always 2 files that they're source code but not in the `src` directory, which makes it hard to search.

- move the content of `index.js` and `standalone.js` to `src`.
- `/index.js` and `/standalone.js` are preserved as links to not break builds that's installed from git.
2018-09-06 13:51:18 +08: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
Ika 50c9115632 feat: add printer.preprocess (#5041)
Sometimes we need to transform the ast to make it easier to print, but it's currently done in the parser (markdown and yaml), which leads the output ast harder to use for external users (custom parser), adding `printer.preprocess` can solve this issue.

And also this way we could move the trailing newline for json from `ast-to-doc.js` to `language-js`.
2018-09-03 23:27:50 +08: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
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 55e620bdc7 chore: extract jest snapshot serializers (#5034) 2018-09-01 12:11:19 +08:00
Ika 49e2f77bff refactor: extract options-normalizer/validator (#5020)
- Uses [`vnopts`](https://github.com/ikatyang/vnopts#readme)
- This way it should be easier to support language-specific options (https://github.com/prettier/prettier/pull/4798#issuecomment-407258477) and map the common options to language-specific options using [`forward`](https://github.com/ikatyang/vnopts#forward), e.g. `singleQuote: true` -> `"javascript/singleQuote": "js"`, `singleQuote: false` -> `"javascript/singleQuote": "none"`.
2018-08-31 11:26:07 +08:00
Ika 32390cd6a3 fix(vue): do not pass <script src> into multiparser (#5031) 2018-08-31 09:28:55 +08:00
Ika 58d34bb844 refactor: language extend (#4994) 2018-08-22 10:12:57 +08:00
Ika 1790211f76 feat: support MDX (#4975)
* feat: support MDX

* refactor: flip condition
2018-08-13 22:23:09 +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
Ika 82a12a58a8 fix(config): better error message for unsupported extension (#4969) 2018-08-11 16:35:18 +08:00
Ika 26fd292ece Bump Prettier dependency to 1.14.2 2018-08-09 11:05:58 +08:00
Ika 98cca8f66f Release 1.14.2 2018-08-09 11:04:36 +08:00
Ika 53c83f97f5 fix: guess line ending before preprocess (#4957) 2018-08-09 10:51:08 +08:00
Ika 3842cbb118 fix(typescript): use the first error when both failed (#4947) 2018-08-09 10:21:00 +08:00
Ika 4fb2070244 Bump Prettier dependency to 1.14.1 2018-08-09 00:38:53 +08:00
Ika 35d0ff1d3f Release 1.14.1 2018-08-09 00:36:36 +08:00
Ika 8973caf4bb chore: improve release scripts (#4933)
- use the latest git tag as the previous version
- restore/bump the version on master in `bump-prettier.js`
- use `stdio: "inherit"` for `npm publish` so that we could input the OTP
- do not use `--runInBand` for local `test:dist`
- remove `Updating integration snapshots`
- remove `Attach all files in dist/ folder`
2018-08-08 23:49:22 +08: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
Ika e72cb538f9 fix: update flow support info (#4943) 2018-08-08 23:47:49 +08: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
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
Ika 1915cc3c46 chore: enable glimmer parser on preview playground (#4915) 2018-08-01 15:44:37 +08: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
Ika 4b8e18f978 docs(related): add prettylint (#4914) 2018-07-31 01:21:31 +08:00
Ika 440ab4f60b refactor: upgrade to cosmiconfig@5 (#4899)
* refactor: upgrade to cosmiconfig@5

* fix: use custom require
2018-07-29 16:57:36 +08:00
Ika 435e8532cb docs(changelog): fix link 2018-07-29 15:54:05 +08:00
Ika 78ca79e6b7 chore: bump master version to 1.15.0-dev 2018-07-29 15:52:03 +08:00
Ika 514fcb835a chore: bump Prettier dependency to 1.14.0 2018-07-29 15:44:21 +08:00
Ika 9bac11907c Release 1.14.0 2018-07-29 15:33:12 +08:00
Ika c2d90f14d8 docs(blog): 1.14 release (#4857) 2018-07-29 15:25:22 +08:00
Ika f0f45a2621 chore(scripts): fix checkSchema command 2018-07-29 15:04:33 +08:00
Ika 86614bd16d docs(precommit): add missing @next for husky 2018-07-28 13:51:18 +08: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
Ika 02f64af6e3 fix(vue): no error on range format (#4868) 2018-07-22 15:58:29 +08:00
Ika 1fe0b01bd4 fix(yaml): no wrong loc info for CRLF (#4863)
Context: https://github.com/prettier/prettier/issues/4856#issuecomment-405982539

Workaround for eemeli/yaml#20
2018-07-19 21:50:27 +08: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
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 b1c0c8c8d6 refactor(typescript): remove unnecessary experimental types (#4819)
Ref: eslint/typescript-eslint-parser#429
2018-07-10 10:05:31 +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
Ika 99c4e41fa1 feat: format yaml front matter (#4773)
* refactor: front-matter

* feat: format yaml front matter
2018-07-03 09:54:40 +08:00
Ika e9f489cea1 refactor(debug-repeat): use built-in int type (#4791) 2018-07-02 16:01:05 +08:00
Ika c4be0a57c3 feat(playground): add description for options (#4785)
* feat(playground): add description for options

* fix: support opposite description

* refactor
2018-07-02 08:23:21 +08:00
Ika 9bb8edf96a feat: support .js.flow (#4777)
* feat: support .js.flow

* feat: add Flow language entry
2018-07-01 16:18:08 +08:00
Ika b4a92c6ee5 feat(playground): use real code sample (#4770)
* feat(playground): double click to insert example

* fix: correct condition

* feat: real code sample

* fix: remove unnecessary updateValue

* feat: auto-select on focus
2018-07-01 16:17:25 +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 0b659b898d feat: update linguist languages (#4741)
Context: https://github.com/prettier/prettier/pull/4734#issue-196702272

Languages should be easy to maintain now.
2018-06-28 08:24:02 +08:00