Commit Graph

421 Commits (dc93bdc983b9caa43aaee7efdba792f5d304dbc1)

Author SHA1 Message Date
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
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
Christopher Chedeau ee1717e7b7 Make comments around empty parenthesis be inside (#957)
The logic was already implemented in #802 but for a single case. I just added all the cases added in the awesome @umidbekkarimov

Fixes #956
2017-03-09 07:55:18 -08:00
Christopher Chedeau c2aacae54c Fix `in` inside of a for in a nested way (#954)
Fixes #907
2017-03-08 17:09:37 -08:00
Alex Rattray 24c314da01 Recursively find leading comments inside ReturnStatements (#955) 2017-03-08 17:06:18 -08:00
Karl O'Keeffe 68a39454af Do not break long `describe` calls (#953)
This ensures that `describe` calls in test suites are whitelisted in the same way as `it` and `test` and never break across lines.
2017-03-08 13:24:28 -08:00
James Henry 72456bf06f [WIP] TypeScript Parser (#915)
* WIP immediate feedback

* typescript parser is drop-in replacement for flow parser

* Add new TypeScript Parser snapshots where drop-in replacement possible

* Snapshot updates after rebasing

* Remove unnecessary stripping of properties on TypeScript parser AST

* Remove annotated issues

* Move TS dependencies to dev for now
2017-03-08 13:18:13 -08:00
Kevin Gibbons dc2fa2cdd0 Fix #951: properly parenthesize ** expressions (#952) 2017-03-08 13:11:53 -08:00
Kevin Gibbons 7443f4cbd6 Parenthesize function expressions in expression position (#941)
* refactor needsParens for function expressions

* snapshots

* comment
2017-03-07 18:53:42 -08:00
Alex Rattray 50602aecbb [JSX] Break if opening element breaks (#942) 2017-03-07 17:19:05 -08:00
Kevin Gibbons 06987e9948 cleanup needsParens (#935) 2017-03-07 14:43:05 -08:00
Davy Duperron 1b6ddf9a7f Fix binary op as body in arrow expression (#921)
* Implement new logic for wrapping binary op in arrowFunctionExpression.

* Add new test cases.

* Reuse new helper function in order to fix #917.

* Add new test case.

* Extend heuristic to dive deeper into mixed types.

* Add new test.

* Enhance logic to cover more cases.

* Add new test cases.

* Disable Flow as it gets BindExpression as an unexpected token.

* Simplify getCombinedDeepest function.

* Add missing case.

* Extract all conditions in switch cases to one top level condition.

* Refactor implementation to make it cleaner and also handle ExpressionStatement.

* Update related test cases.

* Add new test case.

* Make condition less expensive.

* Clean up unecessary conditions, simplify condition involving startsWithOpenCurlyBrace.

* Update and add new test cases for better coverage.

* Remove unecessary condition, refactor canBeFirstInStatement to drop some useless parens.

* Update test cases accordingly 🚀.
2017-03-07 13:24:47 -08:00
Davy Duperron 008ac1c479 Fix files with comments only (#813)
* Add new handleOnlyComments function.

* Update tests.

* Update test as the printer forces a trailing newline if there were any contents.

* Implement a different heuristic.

* Update tests.

* Add directives checking in handleOnlyComments function.

* Add directives checking in handleOnlyComments function (amend to retrigger CI).

* Remove duplicate.
2017-03-07 11:02:45 -08:00
Kim Joar Bekkelund a5ad490467 Do not break long it/test calls when template literal (#893)
* Do not break long it/test calls when template literal

* expressions and newlines
2017-03-07 08:36:03 -08:00
Davy Duperron 4dde054bb3 Fix binary expression instanceof in arrow function expression (#913)
* Add fix for parens of BinaryExpression with instanceof op embedded into ArrowFunctionExpression.

* Add new test 🚀.
2017-03-06 03:44:48 -08:00
Simon Lydell b91d6384a6 Fix 0.5e0 (#911)
* Don't generate invalid scientific notation

Fixes #902.

* Remove unnecessary scientific notation (1e0)
2017-03-06 03:44:05 -08:00
Davy Duperron 3f6259554e Fix broken export comment (#899)
* Add new helper function to convert comments as blocks in ExportNamedDeclaration.

* Add new test.

* Switch to a leading position.

* Update test accordingly.
2017-03-05 21:49:07 -08:00
Brian Ng f6bbc2ed2e Fix bug with importing empty type (#904) 2017-03-05 19:08:42 -08:00
Davy Duperron c852d1631c Fix unprinted comments in destructuring (#898)
* Add handlePropertyComments printing function.

* Add new test.
2017-03-05 14:40:03 -08:00
Davy Duperron 2ef9896567 Fix object expression in arrow function expression (#897)
* Add new case for keeping parens around ObjectExpression in ArrowFunctionExpression.

* Add new test.
2017-03-05 13:04:50 -08:00
Brian Ng 860a9fd6d4 Ensure no parens for JSX inside of an ArrayExpression (#895) 2017-03-05 08:56:07 -08:00
Brian Ng 226fd85d8f Fix paren removal on UnionTypeAnnotation (#878) 2017-03-03 17:37:00 -08:00
Christopher Chedeau be7b5ea120 Run 0.21.0 (#876) 2017-03-03 15:39:37 -08:00
Christopher Chedeau 7d24b0a1ff Fix flow union comments (#853)
The comments infra has been architected with trailing operators and fails for leading `|`. Instead of having leading comments, we can put trailing comments on the previous one and use the same technique as assignment to deal with the indentation.

Fixes #849
2017-03-03 13:54:45 -08:00
Christopher Chedeau 184382dd00 Do not break long it calls (#842)
This happens very frequently that naming a test makes the entire line go > 80 columns and requires to indent everything which takes a lot more space. We've had this being reported multiple times and it also affects a lot of tests inside of fb.

Fixes #159

(Note, this is built on-top of #841 but github doesn't handle stacked pull requests well...)
2017-03-03 16:48:29 -05:00
Christopher Chedeau fe38dab45a Fix comment for `call( // comment` (#858)
This is a pretty exotic way to put a comment and it's been a long time since I have seen prettier output be as broken :)

Fixes #857
2017-03-03 16:47:13 -05:00
Christopher Chedeau 735f07fa4f Do not put \n after label (#860)
This is a leftover from the recast prototype, it hasn't been touched since then. I have never seen anyone not put the label on the same line.

Fixes #859
2017-03-03 16:46:40 -05:00
Christopher Chedeau fa9dca362e Add parenthesis around assignments (#862)
This is a neat trick from the React codebase. It helps highlight the fact that this is an assignment and not a comparison which is subtle to realize.

Fixes #861
2017-03-03 16:46:11 -05:00
Christopher Chedeau 5523c4f56b Inline short expressions for boolean operators too (#826)
In #605 I restricted it to binary operations as I didn't know how it would affect boolean operations but it turns out the same technique solves problems that people are reporting. So doesn't make sense to restrict it.

Fixes #824
2017-03-02 22:45:26 -05:00
Christopher Chedeau 3649835ce0 Keep parenthesis on export default function (#844)
It turns out that my fix was not correct. We should not add parenthesis for FunctionDeclaration instead of checking if the function expression is named.

Fixes #819
2017-03-02 22:39:22 -05:00
Christopher Chedeau 211e18bed2 Inline last arg function arguments (#847)
```js
SuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLongCall((err, result) => {
  // comment
});
```

currently breaks into

```js
SuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLongCall((
  err,
  result,
) => {
  // comment
});
```

which looks bad, instead this PR makes it break

```js
SuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLongCall(
  (err, result) => {
    // comment
  }
);
```

which look better
2017-03-02 22:29:53 -05:00
Christopher Chedeau 4b237d331e Fix jsx expression comment that break (#852)
In #596, I fixed a bunch of jsx expression comment edge cases and happened to add a softline there. But it turns out that it's not needed and is actually harmful :)

Fixes #712
2017-03-02 22:27:08 -05:00
Christopher Chedeau 516f5900d8 Stabilize import as comments (#855)
Since this is extremely rare, I just took the easy way out and if you are adding a comment inside the "as" node, I just move it outside. We could be more fancy but that works.

Fixes #620
2017-03-02 22:22:33 -05:00
Christopher Chedeau 705ac7d3cf Do not break require calls (#841)
This has come up a couple times on the issue tracker on the react-native-web discussion about Twitter internals. It seems like there's a concensus that people don't break long require calls and they'd rather have it go > 80 columns.

Fixes #303
Fixes #752
2017-03-02 22:21:02 -05:00
Christopher Chedeau d90af427fb Fix comment after the last argument of a function (#856)
The issue is that the comment algorithm attaches it to the return type / value but we want to attach it to the previous one.

Fixes #612
2017-03-02 22:17:22 -05:00
Alex Rattray 475208d22a [JSX] Don't wrap JSX Elements in parentheses if they are inside JSX Expression Containers (#845) 2017-03-01 12:05:57 -08:00
Christopher Chedeau 198a9e4e49 Run prettier 0.20.0 (#835) 2017-03-01 09:37:02 -08:00
Alex Rattray aef1ac61c9 [JSX] Break before and after jsx whitespace (#836) 2017-02-28 13:30:54 -08:00
Christopher Chedeau d6e3815c19 Allow breaking for logical expressions in member chains (#827)
I'm not really sure what a general rule is for those, but starting with LogicalExpressions should be good. Outside of identifiers, function calls and logical expressions, there aren't a lot of things you'd put there in real code anyway.

Fixes #822
2017-02-28 09:31:04 -08:00
Christopher Chedeau 61482662cc Migrate class comments to the beginning (#831)
Instead of trying to figure out a complicated way to preserve their correct position, it's easier to just migrate those comments before the class.

Fixes #693
Fixes #694
2017-02-28 11:23:15 -05:00
Christopher Chedeau 2ea1dbcb6a Fix indentation of a merged group (#828)
Printing a merged group indented was actually not the right fix. The right fix was to print them in a single line. It used to have this behavior when I was mutating the first group but now that I don't anymore I need to reproduce this condition.

Fixes #823
2017-02-28 10:55:32 -05:00
Christopher Chedeau c17bcabc0b Preserve new lines for comments after `=` (#830)
The `hasLeadingOwnLineComment` helper is going to be useful for other places where we just used `n.comments` as a proxy for it.

Fixes #660
2017-02-28 10:00:28 -05:00
Christopher Chedeau 4540f473e9 Put short body of arrow functions on the same line (#829)
By adding a group, we can avoid adding a newline if the expression fits in a single line.

Fixes #800
2017-02-27 17:18:43 -05:00
Christopher Chedeau 08b8a5f2e7 Do not put parenthesis around not named default export (#819)
We need to add parenthesis around function expressions if they are named otherwise the name leak, but if the function is not named then it's just superfluous.

The conditional change is due to a bad use of switch case where it would fall through the next one. We don't want parenthesis there.
2017-02-27 16:46:17 -05:00
Christopher Chedeau 443a5d6d66 Properly support `do` (#811)
The code that supported `do` was likely from some recast time and didn't work anymore.
2017-02-27 10:49:08 -05:00
Davy Duperron 04f09ddc80 Fix function call args (#809)
* Implement new heuristic for arguments in printArgumentsList function.

* Remove unwanted modification.

* Add new helper function.

* Update tests according.

* Add new tests for #682, #677, #253.

* Move heuristic in groupLastArg condition.

* Update tests.
2017-02-25 09:56:13 -08:00
Davy Duperron b32ace8934 Fix function declaration params comments (#802)
* Add new handleFunctionDeclarationComments function.

* Add dangling comments printing for function params.

* Add new test case.

* Update tests.

* Refactor handleFunctionDeclarationComments to only addDanglingComment when no params.

* Remove unecessary helper function, only attach dangling comments when no params.

* Reset flow tests, no more regression.
2017-02-24 07:26:30 -08:00
James Long cea254857a Eagerly evaluate `ifBreak` when processing template literals (fixes #795) (#798) 2017-02-23 21:21:13 -08:00
Christopher Chedeau 2111f1152c Fix empty options (#803)
```js
// test.js
var prettier = require('./');
prettier.format('a=1');
```

```js
node test.js
// doesn't crash
```
2017-02-23 23:34:53 -05:00
Davy Duperron c8c1875fc8 Fix extra parens for update expressions (#796)
* Remove parens around UpdateExpression when parent is CallExpression.

* Add new test case.
2017-02-23 11:54:06 -08:00
Christopher Chedeau 7c4654b7a3 Run prettier on 0.19.0 (#793) 2017-02-23 09:57:51 -08:00
Christopher Chedeau c9d2c17bc7 Fix tests on node 4
Turns out, if you don't put "use strict"; `const` behaves in a crazy way.
2017-02-23 09:47:06 -08:00
Christopher Chedeau 1d02ca7849 [RFC] Add parenthesis around && inside of || (#780)
It seems like precedence for this combination of operators is very unclear to people (myself included) and consistently adding parenthesis there would be good.

Fixes #773
2017-02-23 09:27:00 -08:00
Christopher Chedeau e50aaeccfb Introduce line-suffix-boundary (#750)
The idea is that if you reach the end of the `}` inside of a template literal, we have to flush the trailing comma, otherwise it would generate invalid code. We also need the same special case for JSX.

I don't like adding yet another type of document but it seems like the most elegant way to solve the problem.

Fixes #623
2017-02-23 09:26:26 -08:00
Davy Duperron 260a141dbe [WIP] Fix comments in template literals (#643)
* Add handleTemplateLiteralComment helper function.

* Fix handleTemplateLiteralComment function.

* Extend handleTemplateLiteralComment to deal with trailing comments 🚀.

* Add test.

* Make handle comments function naming more consistent, fix merge conflicts.

* Update tests.

* Add better comment injection in Template Literal.

* Pass options to attach function.

* Update tests to match new implementation.

* Fix let -> var in findExpressionIndexForComment for NodeJS v4.

* Reorder after merge conflicts.

* Drop old tests for dangling arrays.

* Replace redundant conditional by a boolean 🚀.

* Refactor implementation.
2017-02-23 09:23:56 -08:00
Christopher Chedeau ee0e839cb8 Do not put trailing commas for function declaration in es5 mode (#791)
Fixes #789
2017-02-23 09:01:19 -08:00
James Long 5f78e78081 Do not format template literals (#749) 2017-02-23 09:00:29 -08:00
Christopher Chedeau 6b7aa83820 Group [0] at the end of the previous chain instead of beginning of next one (#784)
Fixes #775
2017-02-23 07:34:52 -08:00
Christopher Chedeau 694816517a Do not expand empty catch (#783)
I originally wanted to expand it but I think that it may not be a good decision because it's very common for them to be empty and you want it to take as little space as possible.

I tried to remove all those conditions but I think that there are valid places where we always want to expand like empty if/for/while loops.

Fixes #778
2017-02-23 07:29:05 -08:00
Christopher Chedeau c84027745b Add `this` for Member factory whitelist and remove softline (#782)
In addition to Observable, $ or _, we should also add `this` to the list of things that are likely factory and not objects you want to apply things on directly.

I added a way to make the function call break on its own line when it doesn't fit in one line and indent. But I think that only having the indentation is enough, having the call on its own line feels weird.

Fixes #777
2017-02-23 09:41:44 -05:00
Christopher Chedeau 0241d97b77 Do not attach comments to EmptyStatements in try/catch (#763)
We skip EmptyStatement when generating the list of preceding/enclosing/following nodes but didn't do the same for the exceptions.

Fixes #695
2017-02-22 17:43:29 -05:00
Brian Ng 9c558bfe71 Remove extra parens around ternary arguments of a new call (#776) 2017-02-22 10:28:52 -08:00
Christopher Chedeau 5cc21c5498 Correctly place trailing comments in conditionals (#754)
Previously we would blindly put leading comments of the next expression, but we didn't account for a real trailing comment. By checking if the leadingNode is on the same line, we can correctly put it there when needed

Fixes #685
2017-02-20 20:25:30 -05:00
Davy Duperron d613f92f60 Fix missing comments in assignment pattern (#704)
* Add handleAssignmentPatternComments helper function.

* Add new tests 🎉.

* Remove unecessary arg in function.

* Reorder it.

* Experimental fix for key comments in the printComments function.

* Pull master and switch to @vjeux implementation.

* Fix bad rebase.

* Add additional checking for enclosingNode in handleObjectProperty function.
2017-02-20 07:39:08 -08:00
Davy Duperron 01b0692307 Fix leading & operators in flow types (#738)
* Add new logic for & op as IntersectionTypeAnnotation.

* Update flow tests accordingly.

* Update flow types perf tests.

* Remove op variable.
2017-02-20 07:18:39 -08:00
Davy Duperron de8873ab23 Add missing explanatory comment in ForStatement case (#748)
* Add missing explanatory comment in ForStatement case :notepad-spiral:.

* Update comment 🚀.
2017-02-20 10:15:46 -05:00
Davy Duperron c32e0339d0 Fix missing dangling comments in for loop (#742)
* Add dangling comments printing in for loops.

* Add new tests.

* Simplify implementation by moving dangling comments upfront.

* Update tests accordingly.
2017-02-20 09:17:10 -05:00
Christopher Chedeau 135a3dd0a7 Remove extra parenthesis around await inside of unary expression (#745)
Big props to @bakkot for mentioning that yield shouldn't be applied the same treatment.

Fixes #728
2017-02-20 09:14:33 -05:00
Davy Duperron 0f34fb91eb Fix missing dangling comments in arrays (#744)
* Add missing dangling comments printing in arrays.

* Update tests accordingly.
2017-02-19 17:25:18 -08:00
Davy Duperron 1affecc1a0 Fix missing dangling comment in exports (#741)
* Add missing dangling comment injection.

* Update tests.

* Add code comment.
2017-02-19 14:39:09 -08:00
Davy Duperron f106b1ec97 Fix await ternary parenthesis (#740)
* Add missing case.

* Update tests.
2017-02-19 14:31:54 -08:00
James Long 5d131027ce Make trailing-comma option support 2 different modes (#641)
* Make trailing-comma option support 2 different modes

* Add deprecation warning

* Add deprecation warning to API
2017-02-17 22:44:55 -05:00
Christopher Chedeau e30482d440 Fix trailing new lines preservation (#724)
There is an off by one error which made the algorithm not work all the time. In many cases, it actually is the opposite, so whenever you save, it adds/removes that line. I noticed it during the --debug-check run on our codebase but didn't investigate.

Fixes #723
2017-02-16 09:56:12 -05:00
Christopher Chedeau 00e5014e00 Align boolean inside of arrow functions (#691)
We already do it for if/... but it looks weird for arrow function body.
2017-02-15 20:00:02 -08:00
Christopher Chedeau b93a207bb2 Run prettier on 0.17.0 2017-02-15 19:56:11 -08:00
Christopher Chedeau d8c242891b Do not put \n inside of empty object method bodies (#706)
Fixes #703
2017-02-15 20:52:54 -05:00
Christopher Chedeau 7046d978a4 [RFC] Preserve new lines between array elements (#707)
This has come up many times in the past and while going through the fb codebase, there are a few instances where we group array elements logically using empty lines and it's a shame that they are gone.
2017-02-15 20:52:28 -05:00
Brian Ng e0f82cd7d9 Ensure importKind is printed (#718) 2017-02-15 12:56:34 -08:00
Christopher Chedeau 1b37cb0365 [RFC] Remove parenthesis object special case (#689)
I've started the discussion around it but I think that it was a mistake. It feels weird to add parenthesis on object values sometimes but not others. I think that it's best to let prettier do its work on staying under 80 columns based on the rules we added.
2017-02-15 10:20:37 -05:00
Christopher Chedeau 0c00290dd3 Inline objects & arrays as right part of a boolean expression (#692)
This is a common pattern to write default values.
2017-02-15 09:41:06 -05:00
Christopher Chedeau 9a5090a473 Do not inline new as last argument (#705)
We inline function definitions but we shouldn't inline new expressions,

835befebf5 introduced both call expressions and new expressions. Call expressions have been removed but looks like new haven't.
2017-02-15 09:37:01 -05:00
Alex Rattray f73ae2978e [JSX] Don't add newline following newline (#690) 2017-02-14 13:41:51 -08:00
Christopher Chedeau 162ae7b51f [RFC] Introduce prettier-ignore-next (#671)
This was surprisingly easy to write!

Technically, it doesn't ignore the next line but the next expression or block but I'm guessing that people are already used to `// eslint-disable-next-line` so it's going to be an easier learning curve.

Fixes #120
2017-02-13 21:58:50 -05:00
Davy Duperron b661fecd9c Fix comments in return statement argument (#657)
* Extend ReturnStatement case to better handle comments in argument 🎉.

* Update test.

* Add missing space between return and left parenthese.

* Fix current tests and add new tests.

* Do not break one-liner returns.

* Revert specific test.

* Patch from #683.
2017-02-13 18:35:42 -08:00
Christopher Chedeau d09e455a71 Always put a hardline before dangling comment (#675)
In #563 it looked odd that there was no space before `//`, it turns out that we don't automatically go to the new line for dangling comments. I think that we just should no matter what, so this is what this diff does.

Fixes #563
2017-02-13 20:08:58 -05:00
Christopher Chedeau 4dca78dbed Add option for putting > on the last line in jsx (#661)
Feel free to suggest a better name for the option. Otherwise it works great :)

Fixes #654
2017-02-13 12:57:05 -05:00
Davy Duperron 1415040263 [WIP] Fix Flow DeclareTypeAlias (#669)
* Inject source text into printAstToDoc function.

* Add getNodeSource helper function.

* Fix Flow drawback with missing DeclareTypeAlias by checking the node source.

* Add new test.

* Fix getNodeSource helper function.

* Revert text injection.

* Refactor DeclareTypeAlias printing.

* Drop expensive getNodeSource helper function 🗑️.

* Refactor declareTypeAlias case in printer.

* Update tests.

* Implement the same logic for DeclareInterface.

* Update the tests.

* Fix missing semicolons and typo.

* Put Flow specific node detection code into own helper function 🚀.

* Refactor isFlowNodeStartingWithDeclare helper function.

* Simplify isFlowNodeStartingWithDeclare helper function.

* Rename test spec.

* Update tests.
2017-02-13 09:17:20 -08:00
Christopher Chedeau ec6ffbe063 Properly support member chains comments (#668)
When there is a comment right before the first `.`, we want to force break such that the comment is printed on its own line.

Note: this needs to be based on-top of #667 as it always indent the first `.`

Fixes #613
2017-02-13 09:05:18 -08:00
Christopher Chedeau c4b83c7653 Ensure that all comments are printed (#571)
This currently fails for 20 tests. I'm putting this up as a pull request so we can merge it once all the comments are properly printed :)
2017-02-13 09:04:21 -08:00
Davy Duperron 76982ee2f7 Fix Flow union type annotations indentation (#650)
* Add prettier indentation for UnionTypeAnnotation in ObjectTypeAnnotation.

* Update tests accordingly.

* Fix indentation.

* Update a bunch of tests 🚀.

* Switch to a more consistent indentation.

* Fix tests to match new indentation 🚀.
2017-02-13 09:03:56 -08:00
Christopher Chedeau 1a8e97f92b Fix trailing commas with a trailing comment (#664)
The reason why trailing comments on a line work with commas is because of a special `lineSuffix` document that delays printing the content until a \n is printed. But `lineSuffix` only worked for pure string. By making it work with arbitrary documents we can fix trailing commas with trailing comments.

Fixes #538
2017-02-13 10:13:16 -05:00
Christopher Chedeau 287db4a9b6 Stabilize comments inside of ternaries (#666)
Now, all the variations of comments in ternaries are printed the same way.

Fixes #617
2017-02-13 10:12:31 -05:00
Christopher Chedeau 3464092cc4 Soft break the first member of a chain (#667)
Before, we would always concatenate the first `.call()` if the identifier started with a capital letter, but we do want to break if the content of the call doesn't fit in one line.

Fixes #639
2017-02-13 10:07:33 -05:00
Christopher Chedeau abbf0b4c81 Stabilize comments inside of if/then/else before { (#672)
We already have the logic for fixing if/then/else comments but those ones are triggering another codepath.

Fixes #618
2017-02-13 09:55:54 -05:00
Christopher Chedeau 76e599ec97 Avoid unneeded parenthesis for colon with comments (#673)
Because the group was too high up, the comment would be taken into consideration to determine the size and it would break and add parenthesis. Adding a group where we actually want the ifBreak seems to be passing all the existing tests and fixes this edge case.

Fixes #655
2017-02-13 09:55:09 -05:00
Christopher Chedeau 1fed39ae30 Print line-suffix in --debug-print-doc (#676)
I was trying to debug #620 and got confused that it didn't show `//comment1`. Turns out we just fail silently if we can't print a node type. I added support for `line-suffix` and throw if we encounter a node type that we can't print.
2017-02-13 09:46:44 -05:00
Christopher Chedeau c5bfdae5d8 Fix dangling comments for arrays (#665)
It was missing a softline. I copy and pasted the dangling handling for objects.

Fixes #624
2017-02-12 23:09:39 -05:00