Commit Graph

2708 Commits (7920e6fddecaecedc01ee39f48d28286ea3a0712)

Author SHA1 Message Date
Warren Seine 7920e6fdde Add a new `trim` command to trim whitespaces in the current line (#4772) 2018-10-06 20:18:52 +08:00
Mahir Shah 30ec30daa9 Escape Quotes in Glimmer String Literals (#5143) 2018-10-05 22:19:33 +02:00
Jed Fox e9cde7d8d4
Adjust badges on the README (#5189)
* Fix spacing around badges

* Switch the npm downloads badge to weekly

I switched to a weekly statistic since it feels more immediate and “9M/m” is somewhat confusing.
2018-10-05 14:06:53 -04:00
Qiming zhao 6b294affa4 Add coc-prettier (#5191) 2018-10-05 11:41:51 -06:00
Lucas Duailibe 31c92a7237
Fix comment in variable declarator (#5190) 2018-10-05 08:40:16 -03:00
Petter 1244729ad7 Infer via shebang (#5149)
If no file type can be inferred, this attempts to read the first line of a file and extract a shebang, which can be checked against a known list.
2018-10-05 08:47:23 +08:00
Ben Scott ea0954995d Update link to stylelint-prettier (#5186)
It belongs to the prettier organization now
2018-10-03 22:11:36 -04:00
Brian Ng 2283efb437
Fix parens around ternary inside OptionalMemberExpression (#5179) 2018-10-02 20:45:15 -05:00
Brian Ng 5315e6fe7a
Bump babel-related deps (#5180) 2018-10-02 20:44:54 -05:00
Kent C. Dodds b84635f0d0 support script type of text/babel in language-html (#5167) 2018-09-30 12:32:25 +08:00
Simon Lydell f87c82cc4e
Improve glimmer parse errors (#5161)
Instead of showing 80 carets, point out just which line the error was
on, and rely on the original message to point out the "column".

I thought about matching the `----^` in the original message with a
regex and use the length of it as the column number, but unfortunately
the original message does not show the original code (in this example
some whitespace is missing), so it wouldn't work.

Before:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   3 |
```

After:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]   3 |
```
2018-09-30 00:25:45 +02: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
JSON Deppen 80c22d8e39 Fix broken "strings rationale" link (#5163) 2018-09-29 18:01:49 +02: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
Simon Lydell a459743eb2
Update rationale (#5136)
* Clarify semicolon example

* Add rationale for print width

Fixes #5081.

* Link options and rationale

* Add rationale for comments

Refs. #5121.

* Mention that spaces can be used for alignment for --use-tabs

Refs. #4199.

* Add missing word

* Remove bad `istanbul ignore next` example
2018-09-29 09:41:21 +02:00
Simon Lydell 265d9337f6
Update vim docs (#5131)
* Update "Running Prettier manually in Vim" docs

- Add `--stdin-filepath` for parser inference.
- Reword "if you need a little more control" since it can be argued that
this approach gives you _less_ control than the plugins.
- Add note about error messages.
- Add note about cursor position.

* Clean up vim.md

- Replace the out-of-date vim-prettier information with a link to its
readme. Move vim-prettier to the top as compensation for its reduced
part of the page.
- Remove out-of-date instructions.
- Try to provide roughly the same information about Neoformat and ALE.
- Simplify language and formatting.
2018-09-29 09:40:49 +02:00
Simon Lydell dc590e5e4b
Improve documentation for the parser option (#5129)
- Warn about setting parser at the top level. Refs. #4638.
- Remove top level parser from examples. Instead show the most common
options (I also removed printWidth, since we don't recommend changing
it). Refs. #4638.
- Show how to configure the flow parser for .js files. Refs. #4638.
- Update valid options for the parser option, including links and "since
version".
- Clarify babylon vs flow.
2018-09-29 09:40:19 +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
typicode c8d22c6ed5 docs: remove next tag for husky (#5141)
Husky 1.0 was released and isn't behind a `@next` tag anymore :)
2018-09-24 13:31:50 +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
Marek Bodinger 095bfb8404 Add Exponea to users.yml (#5133)
* Add Exponea to users.yml

* Update exponea.svg
2018-09-22 18:05:13 -04: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
Cody Reichert ead9127d70 Add Assertible to users.yml (#5099) 2018-09-15 15:10:12 -04: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
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
Lucas Duailibe c083300e9d Fix debug doc printer for literalline 2018-09-10 13:14:55 -03:00
Ika 9ca10a378f
fix(typescript): add parens for complex nodes in ClassExpression (#5074) 2018-09-10 08:18:30 +08:00
Ernesto García 8283320648 Add Get on Board to list of users (#5072) 2018-09-08 19:55:32 -04: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
Yashu Mittal 3c77c5dcfb Adding CodeCarrot to OCF list (#5069) 2018-09-08 07:38:03 +08:00