Commit Graph

459 Commits (8f9bb3a22374ba4f6efe0d425a6cbe10e5dd4067)

Author SHA1 Message Date
Christopher Chedeau 9cd4517a64 Fix template literal comments (#1296)
The implementation was checking if the comment was inside of the expression range, which seems like a good idea. Unfortunately, the expression range is not what's inside of `${}` but the actual AST node, which incidentally doesn't include comments. So the logic was off and returned `undefined` which threw afterwards.

Another solution is to find the first quasi where start is > comment start. This means that the comment appeared between the quasi before and this one... therefore in the expression before!

The flow parser has issues with unicode where it makes node location invalid, there are likely other places where node locations are off. So instead of throwing with a weird error, let's attach it to the first one if it doesn't work.

Fixes #1293
2017-04-17 11:35:12 -04:00
Janic Duplessis f3155c3fc1 Fix isPreviousLineEmpry on Windows (#1263) 2017-04-14 16:02:19 -07:00
Christopher Chedeau 17051ece2c [WIP] no-semi comments (#1257)
It doesn't yet work but I think it's close
2017-04-13 18:33:46 -07:00
Christopher Chedeau 6a259b60b5 Get rid of fixFaultyLocations code (#1252)
As I was debugging #1248, I found out that the code to fix was actually making things worse. The other two branches are for decorators and deleting some random value of a function. I ran all the tests and the flow object is actually now preserving empty lines and didn't change anything else.

I'd rather remove all those and if something comes up then fix it properly upstream than having those crutches that we don't know why they exist anymore.
2017-04-13 18:32:03 -07:00
Christopher Chedeau 9d616fc840 Remove trailing whitespace (#1259)
In #1257, I discovered that if there's a `""` doc at the end, it's not going to trim the previous one correctly. It also happens to fix a few existing things.
2017-04-13 18:31:49 -07:00
Jason Laster 2078225daa Fix flow union params (#1251) 2017-04-13 17:54:20 -07:00
Christopher Chedeau 97c662b87b Do not inline member expressions as part of assignments (#1256)
This is a regression from #1036 and #1188.

Fixes #1241
Fixes #1236
2017-04-13 20:09:00 -04:00
Christopher Chedeau 1a0067eae4 re-run tests 2017-04-13 09:26:36 -07:00
Christopher Chedeau fe7ebc0cf7 Fix edge cases triggered by newlines in arrow functions (#1217)
This one is pretty crazy. In #927, I changed

```js
concat(["(", join(concat([", "]), printed), ")"]),
```

into

```js
concat(["(", join(concat([", "]), printedLastArgExpanded), ")"]),
```

which makes the example in #1203 look ugly. The crazy thing is that `JSON.stringify(printed) === JSON.stringify(printedLastArgExpanded)`. So they are deep equal but not the same object. In a non-mutative world, this should cause any problem, but we actually mutate those to propagate breaks.

In the break propagation, we only looked at the first one in case of a conditional group. But, because the two were the same object then it also applied to the second one and happened to be the correct behavior! When I changed that piece of code to be two distinct objects, it no longer worked by accident and caused a bunch of weird issues where breaks didn't propagate correctly.

The solution for this case is to propagate the breaks on all the conditions. I'm pretty sure that this is the expected behavior, we want to deeply recurse in all of them, we don't propagate it up the boundary anyway.

The other use case for `traverseInDoc()` is `findInDoc()`, right now it searches for the first conditional group but it seems very arbitrary. I changed it to not search on any and none of the tests are failing, so I think it's safe(tm). If it triggers weird behavior, then it'll at least be expected and not randomly explode at us if we move groups around.

I tried to go through all the conditions for `findInDoc()` but it triggers a few failures (the output look bad). I'm not really sure why. https://gist.github.com/vjeux/5fb7566cc3d65974817d512d1ef6abe1

Fix #1203
2017-04-13 09:21:18 -07:00
Brian Ng 4d9edec4e1 Fix trailing comma for rest element in Babylon (#1230) 2017-04-13 07:10:08 -07:00
Brian Ng 4dfe92a76b Ensure JSXOpeningElement does not break with single text attr on Babylon (#1229) 2017-04-13 07:09:40 -07:00
Christopher Chedeau f68531a45d Fix overflow for last argument expansion (#1224)
In #847, I used a heuristic to find if the element was going to be expanded. But, it wasn't 100% accurate because we couldn't know in which conditionalGroup we would land. We added a way for the parent to tell that function if we should be in `expandLastArg`. By replacing the condition by this variable, it now fixes the issues!

This is so good that adding the right abstraction fixes problems across the board :)

Fixes #997
2017-04-12 20:24:50 -07:00
Christopher Chedeau 4a4e1817be Do not merge member chain if there's a comment in-between (#1218)
Fixes #1198
2017-04-12 17:26:58 -07:00
Christopher Chedeau 5d8ffd0c2e Fix own line last if comment (#1219)
Fixes #1205
2017-04-12 17:26:44 -07:00
Christopher Chedeau ee7cfa9501 Ignore empty statement in switch newline detection (#1220)
Fixes #1200
2017-04-12 17:26:31 -07:00
Brian Ng 3a7559be58 Preserve comment for last arg of ObjectMethod (#1216)
* Preserve comment after last arg of ObjectMethod

* Preserve comment after last arg with default value
2017-04-12 16:32:04 -07:00
Christopher Chedeau ea957ed64a Fix function trailing comment location (#1195)
It turns out that we can't reliably detect with the ast if a comment is before or after the ). In order to fix this same problem with `if` I added the `getNextNonSpaceNonCommentCharacter` function. We can use the same here to fix the problem.

Fixes #933
2017-04-12 14:18:29 -07:00
Brian Ng 32eecabc6d Stabilize comments on ObjectTypeAnnotation (#1214) 2017-04-12 14:13:34 -07:00
Jan Kassens b82220b20f Prittier printing of snapshots (#1190)
This uses a custom snapshot serializer to reduce escaping in snapshot files and
make them easier to read.

Snapshot serializers are documented here:
https://facebook.github.io/jest/docs/configuration.html#snapshotserializers-array-string
2017-04-12 13:41:51 -07:00
James Long 9a5b447c7f Propagate hard breaks within member expressions (fixes #1117) (#1193) 2017-04-12 09:26:27 -07:00
Alex Rattray 36bec87d17 Enable no-semi mode and protect against ASI failures (#1129) 2017-04-11 13:50:47 -07:00
Christopher Chedeau e3aa878187 Allow to break for member expressions after = (#1188)
This should address a concern of #1036
2017-04-11 11:37:46 -07:00
Christopher Chedeau 523f64ff14 Add ability to break for top member expression (#1036)
It turns out that the top member expression doesn't go through the member chain logic. Let's give it the ability to break for now.

Fixes #1031
2017-04-11 11:37:35 -07:00
Christopher Chedeau b6edf96cc4 Improve jsx output for style components (#1144)
* Hug template literals inside of JSXExpressionContainer

We already hug a bunch of things inside of `{}`. It seems that it's a good idea to do it for template literals as well. I don't think I've seen anyone actually indent them.

Fixes #1090

* Inline jsx elements with single template literal expression

If there is a single expression and a single template literal, then a lot of people in the jsx-style world inline it. I've also myself used this for markdown and printed it that way. So we probably should print it that way.

Note that I'm checking for children.length === 1, this means that if there's any whitespace, this is not going to be true and will not enter this case. So it WON'T reformat

```js
<style>
  {`
     color: red;
  `}
</style>
```

into

```js
<style>{`
    color: red;
`}</style>
```

which is great. You have to opt-in to the second style in order to get it.

Fixes #1090
2017-04-11 09:33:02 -07:00
Christopher Chedeau 2e63684ff5 Add parenthesis for no-confusing-arrow rule (#1182)
I'm unclear whether anyone was ever confused by this but the eslint page is kind of compelling

```js
// The intent is not clear
var x = a => 1 ? 2 : 3;
// Did the author mean this
var x = function (a) { return 1 ? 2 : 3 };
// Or this
var x = a <= 1 ? 2 : 3;
```

Adding a parenthesis makes it valid with `{"allowParens": true}` rule. Note that if this option is not enabled, the code would not pass lint in the first place.
2017-04-11 09:20:39 -07:00
Christopher Chedeau e0eb438e7b Add newline for bracket-less arrow functions that return calls (#927)
I've tried a lot of places where to fix this and this is the only one that gives correct results. This is likely not exhaustive but works for that use case. It's been reported twice in issues and I've seen it happen a few other times so we probably want to get it fixed.

Fixes #922
Fixes #797
2017-04-11 08:50:49 -07:00
Christopher Chedeau 636d1af19e Add parenthesis for binary operators (#1153)
Fixes #872
2017-04-10 18:31:52 -07:00
Christopher Chedeau da7c97e0bb Stabilize label comments (#1179)
Fixes #1160
2017-04-10 11:22:35 -07:00
Christopher Chedeau 45796601c4 Fix last comment of an if test (#1042)
This one sucks.

The range of the `test` of `if (a /* comment */) {}` is only `a` and doesn't include the comment nor parenthesis. This means that we have no way to know if the comment is placed before or after the `)` unless you look at the actual source and strip all the whitespace/comments characters to see if it's a `)`...

This happened on the babel source code twice and many times in the fb codebase. I think we need to fix it unfortunately :(

Fixes #867
2017-04-10 11:05:10 -07:00
Christopher Chedeau f51c5daacb Fix comment detection before comma (#1127)
We need to call the `skipToLineEnd` which skips `,` after an inline comment. So we have to put it inside of the while loop as you can have many comments, a comma and then many more comments.

Fixes #964
2017-04-10 11:03:35 -07:00
Christopher Chedeau 0669160adc Fix last argument comment for function declaration (#1176)
We already handle this but forgot to do it for FunctionDeclaration

Fixes #1166
2017-04-10 10:55:29 -07:00
Christopher Chedeau 11ee5529a5 Add parens around arrow function return type (#1152)
Fixes #1151
2017-04-10 10:51:31 -07:00
Christopher Chedeau 3d64e789b5 Improve printing of chained interesctions (#1155)
Now properly indents all the combinations of objects and non objects.

Fixes #1076
2017-04-10 10:50:38 -07:00
Christopher Chedeau 6bff3f2de8 Fix switch new lines (#1156)
.#1136 accidentally removed all the empty lines between statements inside of switch cases. I just brough back the logic and made sure to only use it for everything but the last line.
2017-04-10 10:50:02 -07:00
Christopher Chedeau 8cc5f22090 Fix parenthesis when call inside of new (#1169)
Fixes #1167
2017-04-10 10:49:13 -07:00
Christopher Chedeau 6552257ab0 Stabilize else comments (#1177)
In #544, I fixed it for all the cases but didn't check for else :(

Fixes #1161
2017-04-10 10:46:44 -07:00
Christopher Chedeau 3eda5fb885 Print return dangling comment (#1178)
Fixes #1157
2017-04-10 10:46:25 -07:00
Christopher Chedeau 0e2bc09409 Properly handle \r\n in JSXText (#1170)
Fixes #1168
2017-04-09 16:37:54 -07:00
Davy Duperron d1191adce6 Fix ampersand in jsx href and src (#1056)
* Add exceptions for html escape usage in href and src attributes.

* Add new test cases.

* Remove useless spaces.

* Do not escape if the parser does not do so.

* Implement a different heuristic for keeping along with the parser.

* Update tests.

* Forgot passing options as param.

* Experimental alternative implementation.

* Remove other function.

* Push test after merge.

* Update getJsXRawValue in order to return the unprocessed raw value.

Latest Babylon version includes a fix that allow us to directly
inject the unprocessed raw value available in the `extra.rawValue`
property of the node. A last transformation is applied by replacing
double quotes to `&quot;` entities.

* Drop unused htmlEscapeInsideDoubleQuote function.

* Move getJSXRawValue function logic to the its only call, drop it.

A simple check is performed to determine if the parser is babylon or
flow via `n.value.extra`. Thus, the corresponding raw value is
extracted. If we are converting a string from single quotes to
double quotes, we need to make sure that double quotes are converted
to &quot;.

* Remove ambiguous comment.

* Add Babylon parser.

* Update test cases accordingly, revert regression introduced previously.
2017-04-08 07:55:50 -07:00
Simon Lydell dc93bdc983 Sync the Flow tests (#1163)
* Extract custom tests from tests/flow/

Approach:

1. Remove all .js files in tests/flow except .snap.js files.
2. Copy over all .js files from tests/ in the flow repo.
3. Go through the diff looking for deletions.
   - It was easy to see which deletions were due to changes in the tests
     due to updates in the flow repo.
   - For the rest of the deletions, I used `git blame` to verify that
     they had been added by us since the flow tests were copied over.

This makes tests/flow/ simply a copy of the tests from the flow repo,
making it easier to sync with the upstream flow tests in the future.

* Add a script for syncing the flow tests

* Sync the flow tests
2017-04-08 07:52:38 -07:00
Christopher Chedeau 41dee70795 Allow to break after = for strings (#1142)
This is not a general fix but it solves some issues that people are seeing where prettier goes > 80 columns.

Fixes #1141
Also fixes part of #1110
2017-04-07 10:51:02 -07:00
Christopher Chedeau 6b806d4411 Re-run snapshot tests 2017-04-07 09:37:53 -07:00
Christopher Chedeau f69b26081f Stabilize VariableDeclarator comments (#1130)
Fixes #932
2017-04-07 07:57:44 -07: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
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
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
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
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
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 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
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
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 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
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
Royce Townsend 9eb389b9f4 Group first arg for inline functions (#947)
* Group first arg for inline functions

* Group first arg. Unless there are comments.

* Group first arg. Allow second arg to be empty object/array.

This implementation has a side effect of disallowing empty objects/arrays in the should group last arg heuristic.
2017-03-18 11:20:07 -07:00
James Long eeae443b43 Separate `if` and `else` groups (fixes #616) (#1032) 2017-03-17 14:02:35 -07:00
Christopher Chedeau dc52a71923 Inline class expressions for bracket-less arrow functions (#1023)
I could go either way but it doesn't seem a big deal to inline them. I don't expect it to be very common anyway

Fixes #990
2017-03-17 14:01:17 -04:00
Christopher Chedeau 16ed595086 Preserve comment position for last arg or method (#1025)
In #856, it handled a bunch of cases but missed class methods

Fixes #905
2017-03-17 14:00:01 -04:00
Christopher Chedeau 35547993d4 Add breakParent support for willBreak (#674)
* Add breakParent support for willBreak

Fixes #615

* Update snapshots from previous commit
2017-03-17 13:51:22 -04:00
Davy Duperron 748dcbf70d Fix import declaration comments (#1030)
* Add handleImportDeclarationComments function.

* Fix indent.

* Update test cases accordingly.

* Implement better heuristic for adding comments.

* Make the test case more exhaustive.
2017-03-17 08:11:43 -07:00
Davy Duperron dde8463ad9 Fix additional empty line switch case comment (#936)
* Refactor condition in printStatementSequence, add new helper function.

* Add new test cases.

* Move logic in SwitchCase case.

* Revert unrelated changes, remove unecessary variables.

* Use util.getLast helper function.

* Move variables out of the loop.

* Simplify code.

* Fix mapping with mutated path.
2017-03-17 08:08:36 -07:00
Hampus Ohlsson 76e26f08a0 Fix dot notation in decorators (#1029) 2017-03-16 13:27:20 -07:00
Davy Duperron 915967b974 No parenthesis for Flow shorthand with one arg (#972)
* Implement checking for not printing the parens in this case.

* Add test case.

* Remove parent type checking.

* Fix test accordingly.

* Refactor to a better heuristic.

* Add new test cases.

* Fix implementation.

* Fix unnecessary function call.

* Add new test cases 🚀.

* Use isObjectTypePropertyAFunction and create isTypeAnnotationAFunction.

* Add missing space.

* Add new test cases.
2017-03-16 10:32:59 -07:00
Christopher Chedeau 3a80345e0c re-run snapshot tests 2017-03-15 18:54:34 -07:00
Brian Ng b8a7e5166b Add parens for ConditionalExpression inside JSXSpreadAttribute (#1015) 2017-03-15 18:52:31 -07:00
Davy Duperron c82bb4e003 Fix exports (#998)
* Fix printExportDeclaration function.

* Update tests accordingly.

* Remove commented line.

* Run npm test -- -u to update and fix tests.
2017-03-15 16:29:15 -07:00
Christopher Chedeau 7105f972b4 [RFC] Add softline to assignment of binary expressions (#871)
Printing the first line of a binary expression next to the `=` leads to weird cases where the first expression is parenthesised and doens't read well with chained conditionals as they don't align well. This makes it behave the same was as `if` tests.

Fixes #863
2017-03-15 09:45:40 -07:00
Dan Harper 332babe77d Fix single optional arrow param printing (#1002) 2017-03-15 09:38:13 -07:00
Brian Ng a2b560887c Add support for breaks in TupleTypeAnnotation (#1003) 2017-03-15 09:35:22 -07:00
Christopher Chedeau 36a1d12f47 Do not respect newlines for object destructuring pattern (#981)
This was intended for object expressions. I tried to remove it for ObjectTypeAnnotation but it changes a ton of stuff as it's used all over the place in many different contexts. We should clean it up but in a later PR :)

Fixes part of #975
2017-03-14 18:36:35 -07:00
David Hong 411f0fb6e7 Print line/mixed comments on new lines inside JSXEmptyExpression (#985) 2017-03-10 18:23:11 -08:00
Christopher Chedeau 0aa3617689 Fix for of/in comment on its own line around in/of (#901)
This is pretty edge case-y so i'm taking the easy way out.

Fixes #886
2017-03-09 11:10:55 -08:00
Brian Ng d034564481 Remove parens from chained assignments (#967) 2017-03-09 09:17:16 -08:00
Christopher Chedeau d39facc022 Only allow same-line arrow-less body for explicit nodes (#966)
In practice, trying to allow calls to be inlined is causing a lot of code to look very weird and unstable as seen by the four issues this is fixing. It also requires us to add a conditional group and do hackery around it.

Fixes #959
Fixes #760
Fixes #615
Fixes #625
2017-03-09 09:08:12 -08:00
Christopher Chedeau 9ef8c709bb fix_tests 2017-03-09 08:59:23 -08:00
Brian Ng b8bdb6c243 Inline BinaryExpressions inside JSXExpression (#965) 2017-03-09 07:59:53 -08:00
Christopher Chedeau 35bd29be2c Stabilize comment after object label (#958)
This is the largest firing unstability on the Facebook codebase.

Fixes #906
2017-03-09 07:55:35 -08:00