prettier/tests
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
..
array_spread [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
arrays [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
arrows Inline class expressions for bracket-less arrow functions (#1023) 2017-03-17 14:01:17 -04:00
assignment [RFC] Add softline to assignment of binary expressions (#871) 2017-03-15 09:45:40 -07:00
assignment_comments Fix unstable comments in assignment pattern (#1055) 2017-03-20 18:49:42 -07:00
assignment_expression Remove parens from chained assignments (#967) 2017-03-09 09:17:16 -08:00
async [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
binary-expressions [RFC] Fix comment location for binary expressions (#1043) 2017-03-21 12:13:13 -07:00
bracketSpacing [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
break-calls Add breakParent support for willBreak (#674) 2017-03-17 13:51:22 -04:00
class_comment [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
class_extends [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
classes Parenthesize function expressions in expression position (#941) 2017-03-07 18:53:42 -08:00
comments [RFC] Fix comment location for binary expressions (#1043) 2017-03-21 12:13:13 -07:00
computed_props [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
conditional [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
decorators Fix dot notation in decorators (#1029) 2017-03-16 13:27:20 -07:00
directives [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
do Properly support `do` (#811) 2017-02-27 10:49:08 -05:00
dynamic_import Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
empty_paren_comment Make comments around empty parenthesis be inside (#957) 2017-03-09 07:55:18 -08:00
empty_statement [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
es6modules Update babylon to 7.0.0-beta.4 (#1047) 2017-03-20 12:46:31 -04:00
export [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
export_default [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
export_extension Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
exports Fix exports (#998) 2017-03-15 16:29:15 -07:00
expression_statement Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
first_argument_expansion Group first arg for inline functions (#947) 2017-03-18 11:20:07 -07:00
flow Fix comment sorting location (#1038) 2017-03-20 10:21:54 -07:00
flow_comments Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
flow_generic Add ability for flow generics to break (#1041) 2017-03-20 12:35:30 -04:00
flow_method Fix comment sorting location (#1038) 2017-03-20 10:21:54 -07:00
flow_object_comment Fix comments inside of ObjectPattern (#1045) 2017-03-20 12:42:07 -04:00
for Fix for of/in comment on its own line around in/of (#901) 2017-03-09 11:10:55 -08:00
function [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
if Separate `if` and `else` groups (fixes #616) (#1032) 2017-03-17 14:02:35 -07:00
ignore Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
import Fix import declaration comments (#1030) 2017-03-17 08:11:43 -07:00
interface Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
jsx re-run snapshot tests 2017-03-15 18:54:34 -07:00
jsx-multiline-assign [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
jsx-newlines [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
jsx-significant-space [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
jsx-split-attrs [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
jsx-stateless-arrow-fn [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
jsx_escape Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
jsx_last_line [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
label [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
last_argument_expansion Group first arg for inline functions (#947) 2017-03-18 11:20:07 -07:00
line [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
line_suffix_boundary Introduce line-suffix-boundary (#750) 2017-02-23 09:26:26 -08:00
literal Fix 0.5e0 (#911) 2017-03-06 03:44:05 -08:00
member [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
method-chain Stabilize comment on member chain with three elements (#1039) 2017-03-20 12:32:49 -04:00
new_expression [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
object-prop-break-in [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
object_colon_bug [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
object_property_comment Stabilize comment after object label (#958) 2017-03-09 07:55:35 -08:00
objects Do not respect newlines for object destructuring pattern (#981) 2017-03-14 18:36:35 -07:00
optional-type-name No parenthesis for Flow shorthand with one arg (#972) 2017-03-16 10:32:59 -07:00
preserve_line [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
quotes Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
require [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
rest Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
return Add parens around return for binaryish expressions (#870) 2017-03-18 19:35:09 -07:00
shebang [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
strings Eagerly evaluate `ifBreak` when processing template literals (fixes #795) (#798) 2017-02-23 21:21:13 -08:00
switch [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
tabWith Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
template [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
ternaries [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
test_declarations Do not break long `describe` calls (#953) 2017-03-08 13:24:28 -08:00
trailing_comma [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
trailing_whitespace Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
try [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
typescript/conformance/types [WIP] Add some typescript tests (#1033) 2017-03-19 08:06:52 -07:00
unary [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
unary_expression [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
unicode Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
union_intersection Upgrade to Jest 19 (#762) 2017-02-21 13:59:19 -08:00
update_expression [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
while [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
windows [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00
yield [WIP] TypeScript Parser (#915) 2017-03-08 13:18:13 -08:00