Commit Graph

770 Commits (7a8380772d4db93586bf50abbc95abf138dac7b0)

Author SHA1 Message Date
Christopher Chedeau f69b26081f Stabilize VariableDeclarator comments (#1130)
Fixes #932
2017-04-07 07:57:44 -07:00
Rafael Hengles 728f3fb408 Change prettier-with-tabs to prettier-miscellaneous (#1149) 2017-04-07 07:56:55 -07:00
Rafael Hengles 170e4d558a Refactored option to indent with tabs (#1026)
Refactored option to indent with tabs
2017-04-06 22:49:37 -04:00
Brian Ng 651cce2066 Import new_spread flow tests (#1138) 2017-04-05 17:39:11 -07:00
Brian Ng 2e96574941 Switch to new test syntax for flow predicate tests (#1137) 2017-04-05 16:32:55 -07:00
Lucas Duailibe 8e9fb43841 Fix trailing comment on switch case (#1136)
* Fix trailing comment on switch case

* Use unshift and add another test case
2017-04-05 16:27:14 -07:00
Alex Rattray d0666c3da4 Fix leading comment inside returned SequenceExpression (#1133) 2017-04-05 13:41:35 -07:00
Christopher Chedeau bab9b5b93a Remove trailing spaces 2017-04-05 13:28:02 -07:00
Joseph Savona fe5de43cd7 Fix printing of Flow type number literals (#1128) (#1132) 2017-04-05 13:22:23 -07:00
Lucas Duailibe 69879e23bc Print comment after key (#1131) 2017-04-05 13:10:10 -07:00
Christopher Chedeau 926f9c4dfb Handle unconventional newlines (#1050)
The `\r` test has had to be deleted because jest doesn't properly save and parse the snapshot back.

Fixes #883
2017-04-05 10:54:39 -07:00
Eric Clemmons 61ad2f1d34 "// prettier-ignore" position within comments doesn't matter (#1126)
* // prettier-ignore can be within any part of the comment block

* Add test for // prettier-ignore being anywhere within comments
2017-04-05 10:51:20 -07:00
Eric Clemmons def91efd16 Support "// prettier-ignore" in comment blocks (#1125)
* // prettier-ignore has to be last comment

* Add test for #1109
2017-04-05 10:08:08 -07:00
Gregor Adams 3ddd6c9271 docs(readme) added TOC (#1123)
generate table of contents for readme.

closes #1122
2017-04-05 08:55:26 -07:00
Christopher Chedeau b2c63b291d Fix spread snapshot test (#1119)
See https://github.com/prettier/prettier/pull/1064#discussion_r109787248
2017-04-04 18:44:48 -07:00
Christopher Chedeau 1578e180f4 Add support for flow type spread in .43 and babylon beta8 (#1064)
Fixes https://twitter.com/ryyppy/status/844116626467438592
2017-04-04 14:52:16 -07:00
Christopher Chedeau 6c9cb86a6d Ability for interface to break (#1060)
We break on `class` before `extends` but didn't for `interface`. Now we do in the same way. Also TIL that `interface` was an actual keyword in JavaScript :P
2017-04-04 14:25:17 -07:00
Dara Hak cefec125f7 Update README.md: fixed typo, added links (#1115) 2017-04-04 14:23:52 -07:00
Brian Ng d9a4efcc35 Bump babylon to 7.0.0-beta.8 (#1118)
* Bump babylon version

* Enable flow predicate tests in babylon
2017-04-04 14:21:56 -07:00
Simon Lydell 96b0a33cff Fix printing of exact object flow type annotations (#1114)
Fixes #1089.
2017-04-03 10:24:36 -07:00
Brian Holt eff5af6ca9 Add check method to Prettier Node API. (#1104)
* Add check method to Prettier. Make CLI use that method for list-different

* Catch in check and return false if it throws

* Remove catch/finally from Prettier list-different bin

* remove try catch in prettier bin for list-different
2017-04-03 09:54:10 -07:00
António Nuno Monteiro 2c9af5ffcc refmt -> prettier in emacs support (#1113) 2017-04-02 23:05:30 +01:00
Yatharth Khatri a707dda53b note on styled-with-prettier badge to README (#1095) 2017-03-29 15:26:01 +01:00
Christopher Moeller 7702a2b1e3 Add note to README regarding vim-jsx plugin (#1085) 2017-03-25 08:10:38 -07:00
ChristianHersevoort 04c959d687 Feature/verify against same snapshot (#1087)
* Verify parsers against same snapshot

- Reworked run_spec, now accepts 3th optional array argument for
additional parsers to verify against
- Merged duplicate run_spec configs
- Removed duplicate snapshot data

* Formatted run_spec.js with prettier

* Fixed node4 incompatibility
2017-03-25 08:10:17 -07:00
Karl Horky 862adaf94d Document prettier-ignore (#1082)
Original PR: prettier/prettier#671
2017-03-23 07:33:04 -07:00
Christopher Chedeau 60816af4ce Add support for currying (#1066)
If you write your code in a functional way where you have an arrow function for each argument, it looks better for them to be inline. I can't imagine any case where it would be used in a different way if we limit to a single argument.

Fixes #1065
2017-03-22 13:33:28 -07:00
Christopher Chedeau dd792a2b22 Fix tests 2017-03-22 10:20:42 -07:00
Christopher Chedeau dc0fbf7822 Special logic for flow intersection (#1018)
We started using the same logic for union and intersection but then added a special case for `a & {}`. It turns out that they should be handled completely differently in practice.

The heuristic i'm using is if you go from object to non-object or vis-versa, then inline, otherwise go to the next line and indent (like &&).

Fixes #864
Fixes #1017
2017-03-22 10:01:34 -07:00
Christopher Chedeau 04eba07aab Hug on single object destructuring function (#1022)
This is very common for stateful react functional components. It also matches last object expansion. I think that we should only do that for a single argument in function definitions though, unlike the last for function calls.

Fixes #1019
2017-03-22 09:58:33 -07:00
Brian Ng d8a64dec6c Remove a few node types (#1075)
* Remove NumericLiteralTypeAnnotation

* Remove ExistentialTypeParam
2017-03-22 09:51:36 -07:00
Brian Ng 42910424a1 Fix parsing flow variance on babylon 7 (#1069)
* Enable babylon on variance tests

* Fix parsing flow variance in babylon 7
2017-03-22 09:37:26 -07:00
Davy Duperron dfd42d8306 Fix class method comments (#1074)
* Add new helper function for printing ClassBody comments.

* Update tests.
2017-03-22 09:26:27 -07:00
Brian Ng 41977c293e Add support for ForOfStatement with await flag (#1073)
* Enable babylon on flow async_iteration tests

* Add support for ForOfStatement with await flag
2017-03-22 09:23:57 -07:00
Christopher Chedeau c3199359b0 Revert "Improve snapshot naming" (#1070)
* Revert "Remove mutation in `printBinaryishExpressions` (#1067)"

This reverts commit e7312ad7b2.

* Revert "Make it clear what parser was used in each snapshot (#1068)"

This reverts commit 4f7ae4815b.
2017-03-21 17:38:28 -07:00
Simon Lydell e7312ad7b2 Remove mutation in `printBinaryishExpressions` (#1067) 2017-03-21 14:49:08 -07:00
ChristianHersevoort 4f7ae4815b Make it clear what parser was used in each snapshot (#1068) 2017-03-21 14:47:23 -07:00
Christopher Chedeau ce6e897950 [RFC] Fix comment location for binary expressions (#1043)
The root cause is that we're calling `printComments` with an empty string, meaning that the leading/trailing comments are not correctly inserted at the right location.

So, the way to fix it is to call `p => concat(parts)` but because we're mutating the array in place, it doesn't work. We need to mutate it and create a copy. But, the root call is actually checking the shape of the parts array which our code is now breaking...

```js
          // Don't include the initial expression in the indentation
          // level. The first item is guaranteed to be the first
          // left-most expression.
          parts.length > 0 ? parts[0] : "",
```

The consequence is that binary expressions are no longer indented if the first expression has a comment (but now it places the comment properly!), which seems like a good trade-off.

I'm not sure if we should merge this one or instead refactor this code such that it doesn't rely on mutation and looking at the shape of the printed tree. `printMemberChain` is a good thing to reference for inspiration.

Fixes #946
2017-03-21 12:13:13 -07:00
Erick Romero 24f9cc3a71 Vim readme (#1058)
* Moved Vim info to its own editor folder, started drafting new README

* Finished first draft, ready for PR

* Testing Readme layout

* Removed vim folder
2017-03-20 22:12:10 -07:00
Davy Duperron 389d9d0fad Fix unstable comments in assignment pattern (#1055)
* Add handleAssignmentPatternComments print function.

* Add new test cases.
2017-03-20 18:49:42 -07:00
Christopher Chedeau 553966345a Fix comment sorting location (#1038)
Right now it's only doing one test for begin/end, but in the issue #1037, we have two nodes that have the same start but different end. The current implementation incorrectly sorts them and the identifier ends up being before the container and therefore the comment search doesn't recurse into it.

Fixes #1037
2017-03-20 10:21:54 -07:00
Christopher Chedeau e88e76cf92 Do not use more than one file descriptor at a time (#1048)
@cpojer made a great suggestion to use `fs.readFileSync` instead of the async version. prettier is CPU-bound and if you want parallelism you can spin up many instances of prettier.

Fixes #994
2017-03-20 10:14:33 -07:00
Christopher Chedeau 569791a57a Update babylon to 7.0.0-beta.4 (#1047)
Fixes #700
2017-03-20 12:46:31 -04:00
Christopher Chedeau b012f7531e Fix comments inside of ObjectPattern (#1045)
ast-types was missing a type, I sent a PR on ast-type ( https://github.com/benjamn/ast-types/pull/211 ) which was merged and released (thanks @benjamn for being super quick!). So I'm upgrading ast-types and add the test in this PR.

Fixes #1007
2017-03-20 12:42:07 -04:00
Christopher Chedeau a502bf9f45 Add ability for flow generics to break (#1041)
While looking at an instability on the React codebase ( ba1299acc2 (diff-2550aa3d377452ae29361f5e53c51c10) ), I realized that we don't let them break which makes the code look weird.

So I added the ability for them to break :)
2017-03-20 12:35:30 -04:00
Christopher Chedeau 82d6e0b4ab Unrestrict flow union comments check (#1040)
I was being very careful by checking all the surrounding types but it actually turns out we want this behavior all the time.

Fixes #931
2017-03-20 12:33:42 -04:00
Christopher Chedeau a9185cb30e Stabilize comment on member chain with three elements (#1039)
We already had a special case for it for a group of 2 elements but now that we are also going in this codepath for 3 if we merge, then we need to do the same here.

Fixes #930
2017-03-20 12:32:49 -04:00
Christopher Chedeau f656db7728 update-yarn-lock 2017-03-19 08:54:17 -07:00
Rasmus Eneman e41ed4955d [WIP] Add some typescript tests (#1033)
* Add some typescript tests

* fix: Remove extraneous colon in type parameter constraint

* style: Add missing newline at EOF in TS tests

* feat: Pretty print typescript object type annotations

* feat: Pretty print TSFunctionType

* fix: Type annotations was missing on class properties

* Add a new batch of tests

* Bump typescript-eslint-parser

* Add a new batch of tests and fix a syntax error in previous

* Bump typescript-eslint-parser
2017-03-19 08:06:52 -07:00
Christopher Chedeau c749ddd508 Add parens around return for binaryish expressions (#870)
It looks better when the first element is aligned with the rest and this is consistent with the way we render `if` test.

Fixes #866
2017-03-18 19:35:09 -07:00