Commit Graph
1994 Commits
Author SHA1 Message Date
Georgii Dolzhykovandfisker Cheung bc90973cad Avoid arg expansion that leads to broken code (#10712)
* Avoid arg expansion that leads to broken code

* Preserve new lines and only take comments into account if they break lines

* Add robustness against path state corruption due to throwing

* Refactor

* Remove redundant logic

It solved the same issue but only partially.

* Simplify further

* Refactor path.try, fix callParent issue

* Minor refactoring

* Add istanbul ignore comment

* Add return to AstPath#try

Co-authored-by: fisker Cheung <lionkay@gmail.com>

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2021-04-20 15:02:11 +03:00
Georgii Dolzhykov 1b2c72df10 TS: don't print parens around nested type assertions (#10702) 2021-04-15 00:19:42 +03:00
Georgii Dolzhykov a610179132 Improve lone argument detection (#10672) 2021-04-15 00:19:23 +03:00
Georgii Dolzhykov ae176f2e79 Process conditional groups in mapDoc (#10695) 2021-04-12 18:15:46 +03:00
147c30f7fb Build(deps): Bump @babel/parser from 7.13.13 to 7.13.15 (#10682)
* Build(deps): Bump @babel/parser from 7.13.13 to 7.13.15

Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.13.13 to 7.13.15.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.15/packages/babel-parser)

Signed-off-by: dependabot[bot] <support@github.com>

* Add test for https://github.com/babel/babel/pull/13099

* Test https://github.com/babel/babel/pull/13049

* Test https://github.com/babel/babel/pull/13101

* Add long name test

* Style

* Print necessary parens in `{ a: (b as any) = 2000 }`

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-04-12 18:15:18 +03:00
Patrick Ahmetovic cbdc8aa376 GraphQL: Fix missing space after keyword in anonymous operations (#10689) 2021-04-12 11:50:39 +03:00
Sosuke Suzuki 0cdc62e405 Improve formatting for do expression (#10693) 2021-04-12 04:22:44 +03:00
fisker Cheung 07ae0134e5 JS: Fix duplicated prettier-ignore comments (#10666) 2021-04-12 03:35:13 +03:00
Georgii Dolzhykov 7a5ccc581d Tweak object destructuring in assignments (#10643) 2021-04-06 12:59:14 +03:00
fisker Cheung 24d39a9068 Throw errors for invalid left-hand side assignment (#10416)
* Throw errors for invalid left-hand side assignment

* Fix tests

* FIx tests

* Add tests from https://github.com/babel/babel/pull/12933
2021-03-30 01:40:42 +03:00
Cyrille David 4407d7b1ea Ember / Handlebars: Do not break opening mustache and path (#10586)
* Add failing tests

* Simplify how mustaches are printed

* Add changelog entry

* Fix changelog

* Make test fail

* Remove a wrong group

* Remove another group

* Record the tests
2021-03-29 15:59:19 +03:00
dependabot[bot] 0ecf5171fe Build(deps): Bump @babel/parser from 7.13.11 to 7.13.13 (#10622) 2021-03-29 12:37:10 +00:00
fisker Cheung cc5981227a Add parens for yield in pipeline (#10446) 2021-03-26 10:19:00 +02:00
George Zahariev 99ac66b73a Support for Flow's Indexed Access type (#10594) 2021-03-25 00:32:53 +02:00
Sosuke SuzukiandGeorgii Dolzhykov a49942c1ba Support module blocks proposal (#10417)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-24 18:19:11 +02:00
Sosuke Suzuki f0a612a302 Update @typescript-eslint/typescript-estree (#10589) 2021-03-24 19:39:00 +09:00
fisker Cheung a17d3fb21f Disallow import without argument and new import(…) (#10584) 2021-03-23 09:48:29 +08:00
5a789f52db Build(deps): Bump @babel/parser from 7.13.10 to 7.13.11 (#10546)
* Build(deps): Bump @babel/parser from 7.13.10 to 7.13.11

Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.13.10 to 7.13.11.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.11/packages/babel-parser)

Signed-off-by: dependabot[bot] <support@github.com>

* Format type imports in TSImportEqualsDeclaration

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sosukesuzuki <aosukeke@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-22 18:15:01 +09:00
dependabot[bot] edce20a822 Build(deps): Bump @glimmer/syntax from 0.77.1 to 0.77.2 (#10550) 2021-03-16 18:03:38 +00:00
Georgii Dolzhykov 13744dffa2 Fix edge case with trailing comments in arrow chains (#10543)
* Fix edge case with trailing comments in arrow chains

* Remove handling of args.needsSemi from printComments
2021-03-16 15:51:03 +02:00
dependabot[bot] 72fcf45df3 Build(deps): Bump @babel/parser from 7.13.9 to 7.13.10 (#10523) 2021-03-16 04:07:53 +00:00
Georgii Dolzhykov 6a87ce138a Improve detection of AMD define (#10528) 2021-03-15 00:08:37 +02:00
fisker Cheung 21c81e007d Test json superset (#10493) 2021-03-14 15:04:35 +02:00
Georgii Dolzhykov 2740ea6ee8 Avoid last-argument hugging for number-only arrays (#10517) 2021-03-14 12:15:53 +02:00
Georgii Dolzhykov 169faf39ac Update yaml to 1.10.2 (#10516) 2021-03-14 12:14:08 +02:00
fisker Cheung 3995c2a1a1 Whitelist recovered babel parse errors (#10495) 2021-03-13 22:07:22 +02:00
fisker Cheung 1ce6b8dc3d Fix syntax error on JSON range formatting (#10497) 2021-03-12 00:24:45 +02:00
Georgii Dolzhykov 4ece300581 Fix Flow range formatting (#10505)
* Fix Flow range formatting

* Add changelog
2021-03-10 15:12:27 +02:00
fisker Cheung 02f803ac8d JSON: Only allow +/- number in UnaryExpression (#10434) 2021-03-09 10:58:31 +08:00
046ffb11f9 Support better formatting for curried arrow functions (#9992)
* Support formatting for curried arrow functions

* Fix test file name

* Fix threshold

* Add changelog

* Fix operator for comparing

* Fix return pos

* Fix eslint

* level 2

* Refactor for level2

* Update tests

* Remove concat

* If it fits on one line, print on one line

* Indent second level arg

* Break before last return value

* Use isCallLikeExpression

* Improve printing

* Add tests

* Remove unnecesary condition

* Fix lint problems

* Update src/language-js/utils.js

Co-authored-by: Chris Brody <chris.brody+brodybits@gmail.com>

* Update changelog

* Add ImportExpression

* Add ImportExpression to isCallLikeExpression

* Resolve conflicts

* Address reviews

* Fix ESLint problem

* Fix changelog

* Add tests

* More tests

* Print simple arrow chains on one line

* Don't forcibly break chain when a segment has a return type but no params

* Prevent excessive wrapping in assignments

* Simplify

* Format object bodies like blocks

* Update changelog

* Fix last arg expansion

* Simplify

* Fix arrow chains in assignment chains

Co-authored-by: Chris Brody <chris.brody+brodybits@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-08 23:18:53 +02:00
Sosuke Suzuki c9144daf47 Support TS 4.2 abstract construct types via ts-estree (#10466) 2021-03-06 19:16:51 +02:00
fisker CheungandGeorgii Dolzhykov 8a1ee9ad1b Support JSON6 (#10456)
* Add test

* Support JSON6

* Test

* Print `null` instead of holes

* More tests

* Update changelog

* Style

* Minor refactor

* Fix AST clean

* Fix `Identifier` clean

* Fix AST compare

* Style

* Reword changelog

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-04 19:37:42 +02:00
Georgii Dolzhykov 37aa31e929 Remove hacks for single-element unions/intersections (#10457)
* Remove hacks for degenerate unions/intersection

* Add changelog
2021-03-04 01:21:03 +02:00
Georgii DolzhykovandSosuke Suzuki 5f8fee4d07 Prevent wrapping object properties with short keys (#10335)
* Prevent wrapping object properties with short keys

* Update src/language-js/print/assignment.js

Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>

* Use getStringWidth instead of .length

Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
2021-03-03 01:43:46 +02:00
fisker Cheung 2f384ab24a JSON: More JSON5 data tests (#10453) 2021-03-02 13:43:48 +08:00
fisker Cheung 2edfec5eda JSON: Better error message (#10452) 2021-03-02 13:42:49 +08:00
fisker Cheung ed9e9ab649 Improve json error code frame (#10433) 2021-03-01 10:04:09 +08:00
fisker Cheung 7aff95cac1 Refactor semicolon check (#10355) 2021-03-01 10:03:28 +08:00
fisker Cheung 9324380c53 JSON: Disallow sparse array (#10443) 2021-03-01 09:53:32 +08:00
fisker Cheung ed64ce0f0e JSON: Allow Infinity and NaN (#10451) 2021-03-01 09:14:20 +08:00
Sosuke Suzuki fc396277fc Support TS 4.2 abstract constructor signature (#10418) 2021-02-28 22:00:17 +02:00
fisker CheungandGeorgii Dolzhykov 383e17665e Refactor decorators print (#10296)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-01 02:58:43 +08:00
dependabot[bot]andsosukesuzuki 478107836d Build(deps): Bump @babel/parser from 7.12.11 to 7.13.4 (#10397)
* Build(deps): Bump @babel/parser from 7.12.11 to 7.13.4

Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.12.11 to 7.13.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.4/packages/babel-parser)

Signed-off-by: dependabot[bot] <support@github.com>

* Add unstable AST compare testing

* Remove error tests for this type with babel-flow

* Fix typo

* Add changelog

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sosukesuzuki <aosukeke@gmail.com>
2021-02-26 22:04:53 +09:00
Sosuke Suzuki feacf82892 Update babel/parser to v7.12.17 (#10345) 2021-02-25 18:28:06 +08:00
Georgii Dolzhykov ec27ade49b Heuristic for grouping parameters in method signatures (#10357)
* Heuristic for grouping parameters in method signatures
* Apply the same logic to function declaration and Flow types
* Group only if there is only one parameter
* Don't group if type param has constraints/default or >1 type param
2021-02-23 16:38:56 +02:00
fisker Cheung d544585d87 Make JSON parser stricter (#10346) 2021-02-23 13:33:10 +02:00
Sosuke Suzuki b0d66bb3c6 Support TS 4.1 intrinsic keyword (#10390) 2021-02-22 13:49:49 +02:00
Georgii Dolzhykov 42f8271a1e Indent type assertions in heads of call and member expressions (#10341) 2021-02-20 14:37:08 +02:00
Georgii Dolzhykov 31b3351800 Better formatting for nested await in member/call expression heads (#10342) 2021-02-20 12:50:44 +02:00
Georgii Dolzhykov aef9277ada Print trailing comma for TS type parameters but not type arguments (#10353) 2021-02-20 12:47:56 +02:00