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 :)
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
* 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
* 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.
Adding typescript broke the docs build and is causing issues with create-react-app bundler. Let's use a small hack to hide it from static analysis, but still works in node.
Fixes#986
* Add handleImportDeclarationComments function.
* Fix indent.
* Update test cases accordingly.
* Implement better heuristic for adding comments.
* Make the test case more exhaustive.
* 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.
* 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.
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
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
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#959Fixes#760Fixes#615Fixes#625
* 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
* 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
* 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 🚀.
* 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.