Commit Graph

2656 Commits (1965b74e61a4df147a463eace42cf235abd24467)

Author SHA1 Message Date
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
Barbara He ff4ef426e6 added link to style guideline benefits, fixed issue #4894 (#5062) 2018-09-05 16:11:24 -06: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
Evilebot Tnawi 7fd346ffa1
feat: newline and space utils to shared (#5049) 2018-09-04 23:08:37 +03: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
Eric Sakmar 6288704c41 format jest calls like regular calls (#5011) 2018-09-03 10:15:23 -03:00
Yulia Galuzo 0c7c1bfde4 fix: splitting jsx text correctly (#5006)
Fixes: #4941
2018-09-02 19:59:28 +02: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
Felix Wu e86f08555a Bugfix/ Don't inline pipeline operator with leading ownline comment (#5015)
* 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
2018-09-01 18:38:19 -04: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
Lipis 2e8366a84e
Update tools and dependent project numbers (#5033) 2018-08-31 10:52:37 +03: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
David dda7c265d0 Update configuration to be clearer about js config (#4993)
So in the list, it says to use `prettier.config.js` as your file name for configuring prettier in js. But in the example it has `//.prettierrc.js`. This confused me so I tried both file names. Both these file names work to configure prettier so I updated the docs to reflect that.
2018-08-20 12:33:02 +08:00
Jed Fox a687b9383b
Add a label that exempts issues from auto-locking (#4987)
* Add a label that exempts issues from auto-locking

* Exempt the “awaiting response” label so people can always reply and have their issue reopened
2018-08-19 07:33:20 -04: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
Ika 82a12a58a8
fix(config): better error message for unsupported extension (#4969) 2018-08-11 16:35:18 +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 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
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
Jed Fox a3ab95abe9
Add a pull request template (#4825)
* Add a pull request template

* Run Prettier

* Address review comments

* ’

* If
2018-08-03 06:28:10 -04: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
Ika 42ba638f37
fix(yaml): update parser (#4931)
* test: add tests

* fix(yaml): update parser
2018-08-03 15:10:26 +08: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