Commit Graph

743 Commits (08e4e2c04c1b57ace85110c7e5c285848b62df9a)

Author SHA1 Message Date
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
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
Bill Mill f5ede513eb update the README to add a pre-commit hook (#944)
* update the README to add a pre-commit hook

* remove comments

* better wording

* better quoting

* consistent prettier binary

* move the tr and fix the quoting

* fix quotes one last time
2017-03-07 19:55:43 -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
Patrick Camacho 513b57db3a Update README.md (#928)
typo fix
2017-03-07 11:38:58 -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
Andrey Okonetchnikov 3045829a61 Update lint-staged docs to use husky for less config. (#923) 2017-03-07 09:53:00 -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
Simon Lydell 25bbe1accb Improve readme CLI usage example (#910)
- Use double quotes for cmd.exe support. See #761.
- Remove redundant example and merge it into the previous.
2017-03-06 03:45:16 -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
Jed Watson 74b6466ee7 Add CLI Example to Readme (#909)
Simple change to add a real world example of CLI usage, because it wasn't immediately obvious to me how it should actually look
2017-03-05 21:51:51 -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
David Ascher c8c91d4af3 Fix typo (#891)
I believe that the instructions for pre-commit config are off by a character.
2017-03-04 11:47:35 -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 b570154dd5 0.21.0 2017-03-03 14:03:36 -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 205458a8d1 Introduce -l option (#854)
gofmt has this option and it's very handy for commit-hooks.

Fixes #851
2017-03-02 22:47:36 -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 a91bb5f2ec Fix travis build image 2017-03-02 19:20:45 -08: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
Christopher Chedeau f1548e76bd re-run snapshot tests 2017-03-01 09:11:54 -08:00
Alex Rattray aef1ac61c9 [JSX] Break before and after jsx whitespace (#836) 2017-02-28 13:30:54 -08:00
Christopher Chedeau e09bdd4447 0.20.0 2017-02-28 10:49:30 -08:00