Commit Graph

1523 Commits (4ce28d3ef4f99ed6718545a6b8e0e6f40cbe710f)

Author SHA1 Message Date
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 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
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
Ika 58d34bb844
refactor: language extend (#4994) 2018-08-22 10:12:57 +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 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 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
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
Jorge Gonzalez 7d78ce68ef feat(config): support TOML configuration files (#4877)
* Add initial support for TOML in configuration files

* Missed brace

* Fix snapshots

* refactor: move loadToml to utils

* Use @iarna/toml

* Add tests for loadToml

* Fix test for CI

* Remove jest-extended

* Create snapshot for load-toml

* Add feat to docs

* lint docs

* Use @iarna/toml/parse-string

* Change path string
2018-08-03 06:27:19 -04: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 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
Lucas Azzola a938076ae5
Ignore .git, .svn and .hg directories (#4906)
Fixes #4895
2018-07-30 00:08:51 +10: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
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
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 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
Prashant Andani cdcb7b11c9 Use destructures and refactor code for readability (#4844)
* Use destructuring for readability and optimzations at for loop length property

* Destructure variables for easy maintainability of code

* PR review fix

* refactor: fix linting

* Use destructures and refactor code for better readability

* Remove merge conflict line

* lint before commit
2018-07-17 18:01:44 -03:00
Prashant Andani 12cb8a9688 Use destructuring for readability and optimzations at 'for' loop length property… (#4842)
* Use destructuring for readability and optimzations at for loop length property

* Destructure variables for easy maintainability of code

* PR review fix

* refactor: fix linting
2018-07-16 22:39:41 +08:00
Ivan Babak a7bb71c7e5 fix(perf): convert traverseDoc from recursion to stack (#4776) (#4848)
In addition to a tiny performance improvement outlined below,
the CPU profile of traverseDoc is now more readable.

Also anonymous arrow functions changed to named regular functions
so that they are properly displayed in the CPU profile,
and moved to outer scope where there's no closure
so that they aren't re-created (this change's performance is dependent
on JS engine implementation and optimization details).

Before (profile):
```
7129.9 ms       5.43 %    13349.9 ms     10.18 %    traverseDocRec
7067.4 ms       5.39 %    11285.5 ms      8.60 %      traverseDocRec
  31.5 ms       0.02 %     1031.9 ms      0.79 %      traverseDoc
  23.6 ms       0.02 %    12313.4 ms      9.39 %      traverseDoc
   2.6 ms       0.00 %       0.3 ms       0.00 %      (anonymous)
   1.7 ms       0.00 %       1.7 ms       0.00 %      call
   1.6 ms       0.00 %       1.6 ms       0.00 %      call
   0.5 ms       0.00 %       0.5 ms       0.00 %      conditionalGroup
   0.4 ms       0.00 %       0.4 ms       0.00 %      printDocToString$1
   0.1 ms       0.00 %       0.1 ms       0.00 %      printGenerically
   0.1 ms       0.00 %       0.1 ms       0.00 %      t
   0.1 ms       0.00 %       0.1 ms       0.00 %      ifBreak
   0.1 ms       0.00 %       0.1 ms       0.00 %      (anonymous)
     0 ms          0 %       0.1 ms       0.00 %      forEach

```

After (profile):
```
6937.9 ms       5.37 %    12872.5 ms      9.97 %    traverseDoc
5944.0 ms       4.60 %    11047.3 ms      8.55 %      propagateBreaks
735.7 ms        0.57 %     1358.3 ms      1.05 %      findInDoc
257.9 ms        0.20 %      466.7 ms      0.36 %      findInDoc
0.1 ms          0.00 %        0.1 ms      0.00 %      has
0.1 ms          0.00 %        0.1 ms      0.00 %      printArgumentsList
```

Before (performance):
```
cat ../LspLanguageService.js | NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --stdin-filepath LspLanguageService.js --loglevel debug --debug-repeat 1000 > /dev/null
Debugger listening on ws://127.0.0.1:9229/4b52c027-ef62-49d6-8770-179e805a0f43
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
[debug] normalized argv: {"color":true,"editorconfig":true,"stdin-filepath":"LspLanguageService.js","loglevel":"debug","debug-repeat":1000,"plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","config-precedence":"cli-override","_":[]}
[debug] resolve config from '/Users/ivanbabak/_sompylasar/_github/prettier-2/LspLanguageService.js'
[debug] loaded options `null`
[debug] applied config-precedence (cli-override): {"filepath":"LspLanguageService.js"}
[debug] '--debug-repeat' option found, running formatWithCursor 1000 times.
[debug] '--debug-repeat' measurements for formatWithCursor: {
[debug]   "repeat": 1000,
[debug]   "hz": 7.774598830700336,
[debug]   "ms": 128.624
[debug] }
```

After (performance):
```
cat ../LspLanguageService.js | NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --stdin-filepath LspLanguageService.js --loglevel debug --debug-repeat 1000 > /dev/null
Debugger listening on ws://127.0.0.1:9229/aa76e134-a68c-44ed-89a8-efb68bc46baa
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
[debug] normalized argv: {"color":true,"editorconfig":true,"stdin-filepath":"LspLanguageService.js","loglevel":"debug","debug-repeat":1000,"plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","config-precedence":"cli-override","_":[]}
[debug] resolve config from '/Users/ivanbabak/_sompylasar/_github/prettier/LspLanguageService.js'
[debug] loaded options `null`
[debug] applied config-precedence (cli-override): {"filepath":"LspLanguageService.js"}
[debug] '--debug-repeat' option found, running formatWithCursor 1000 times.
[debug] '--debug-repeat' measurements for formatWithCursor: {
[debug]   "repeat": 1000,
[debug]   "hz": 7.888114977163907,
[debug]   "ms": 126.773
[debug] }
```
2018-07-15 20:02:14 -07: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 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