Commit Graph
150 Commits
Author SHA1 Message Date
Georgii Dolzhykov 4ece300581 Fix Flow range formatting (#10505)
* Fix Flow range formatting

* Add changelog
2021-03-10 15:12:27 +02: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
Georgii Dolzhykov 0a647a0d31 Format assignments more consistently (#10222) 2021-02-16 21:25:11 +02:00
dependabot[bot]andfisker Cheung d0942b8fae Build(deps): Bump @babel/code-frame from 7.12.11 to 7.12.13 (#10226)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2021-02-04 09:42:00 +08:00
fisker Cheung 7836466d67 Test: snapshot parse errors (#9467) 2020-11-06 15:27:04 +08:00
fisker Cheung 9937fd22ba Simplify flow Variance node print (#9571) 2020-11-05 23:10:53 +08:00
fisker Cheung 4295bb2a55 Flow: Improve comment types detection (#9563) 2020-11-04 09:22:30 +08:00
fisker CheungandGeorgii Dolzhykov db90d67c41 Flow: Fix missing parentheses around prettier-ignored arguments (#9553)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-11-02 10:42:31 +08:00
fisker Cheung b239263e23 Flow: support BigIntLiteralTypeAnnotation and BigIntTypeAnnotation (#9523) 2020-10-30 10:22:17 +08:00
fisker CheungandSosuke Suzuki bb31bf481c Refactor function parameters print (#9489)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
2020-10-26 09:22:37 +08:00
Daniel Sainatiandfisker 80a0856107 Support Flow this parameter annotations (#9457)
Co-authored-by: fisker <lionkay@gmail.com>
2020-10-23 20:43:17 +08:00
George Zahariev d59a107f4a Support Flow Enums with unknown members (#9432) 2020-10-20 14:40:18 +08:00
fisker Cheung 08e8b40ac6 Move non-js syntax test out of tests/js/ dir (#9023) 2020-08-22 14:50:54 +08:00
George Zahariev bd8992d53b When default exporting a Flow Enum, do not append semicolon (#8768)
* When default exporting a Flow Enum, do not append semicolon

* Add changelog entry for #8768
2020-07-16 21:50:31 +09:00
dependabot[bot]andfisker 1802a6f6c4 Build(deps): Bump flow-parser from 0.127.0 to 0.128.0 (#8661)
* Build(deps): Bump flow-parser from 0.127.0 to 0.128.0

Bumps [flow-parser](https://github.com/facebook/flow) from 0.127.0 to 0.128.0.
- [Release notes](https://github.com/facebook/flow/releases)
- [Changelog](https://github.com/facebook/flow/blob/master/Changelog.md)
- [Commits](https://github.com/facebook/flow/compare/v0.127.0...v0.128.0)

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

* Fix tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
2020-06-30 13:36:34 +03:00
Simon Lydell 9184743081 Quote and unquote number keys (#8508)
* Quote and unquote number keys

* Add changelog entry

* Add tests for escapes

* Fix idempotency

* Only run flow-repo/ tests with flow

271 jsfmt.spec.js in flow-repo use only the flow parser.
18 use flow and babel.
Now, all of them use only flow.

* Don’t unquote negative numbers

* Don’t quote/unquote numbers in TypeScript

* Quote BigInt

* Fix AST check

* Fix condition

* Fix BigInt to string

* Fix ESLint not recognizing BigInt

* Only quote/unquote “simple” numbers

* No need to clean BigIntLiteral anymore

* Add tests for 1. and .1

* Fix 1. and .1

* Remove unnecessary babel-ts from tests

* Only unquote numbers for babel

* Update changelog
2020-06-18 18:13:25 +03:00
fisker Cheung 82a319898d Flow: fix function type param (#8365) 2020-05-25 16:47:04 +08:00
Georgii Dolzhykov d420202df4 fix(js): comments after superclass (#8312)
* Fix comments after superclass

* add changelog

* refactor

* Organize tests

* Use addBlockStatementFirstComment

* Amend unstableTests list

* Avoid identical comments in tests

* Add tests for `implements`

* Handle comments in interfaces

* Remove an always-false condition

* Almost a fix

* Further fixes

* Add DeclareClass

* Add DeclareInterface, mixins

* Fix extends in DeclareClass

* Fix DeclareClass

* Fix mixins

* Refactor: remove unused parameters

* Add marked dangling comments

* Unify printing of interface for TS and Flow

* Fix unstable interfaces

* Remove comment

* Restore the original behavior for interfaces with multiple inheritance

* Refactoring, tests

* Remove unused code

* Include a file accidentally omitted from the merge commit

* Remove unused type import
2020-05-24 21:53:29 +03:00
Georgii Dolzhykov dee69aa1bb Add tests to close some issues - part 2 (#8290)
* tests for JSX comments, #1463

* add a test for #2761

* add a test for #3878
2020-05-12 14:29:37 +03:00
fisker Cheung 2c8b419837 Test: Fix parsers (#8278) 2020-05-12 19:21:47 +08:00
Georgii Dolzhykov 746fee6fef Add tests to close issues (#8276)
* add tests for #6899

* add tests for #6326

* add tests for #8154
2020-05-11 11:49:04 +03:00
fisker Cheung 7ad515111e Categorize tests part 4(CSS, flow, misc) (#8251) 2020-05-08 01:29:34 +08:00
fisker Cheung b622578896 Categorize tests part 3 (js) (#8249)
* Categorize tests(js)
2020-05-08 00:55:46 +08:00
Georgii Dolzhykov f67f65055b Further improve method chain breaking heuristic (#7889) 2020-04-16 00:07:44 +03:00
fisker CheungandGeorgii Dolzhykov aa3141c24e Wrap tests in describe (#7934)
* Run `format()` in test function

* Wrap `test`s in `describe`

* Update tests_config/run_spec.js

Co-Authored-By: Georgii Dolzhykov <thorn.mailbox@gmail.com>

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-04-10 19:12:01 +08:00
Kevin GibbonsandGeorgii Dolzhykov ada3d08df5 Put space after generator star, not before (#7516)
* Put space after generator star, not before

* remove pr-7516.md, edit pr-3903.md instead

Because the release blog post will be generated from these files.

* edit pr-3903.md

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-02-18 16:27:52 +02:00
fisker Cheung 6e397b2bb2 Fix a failed test on flow parser (#7501)
* Add failed tests

* fix ast diff

* Delete dead code
2020-02-01 18:27:31 +02:00
fisker Cheung 947a174954 Flow: Add support for decorators (#7482)
* Update flow parse options

* Add `decorators` test

* Restore enums

* Add changelog

* Add babel-verify
2020-01-31 08:55:30 +09:00
fisker Cheung eb1e587d2f Flow: Add support for ClassPrivateProperty (#7484)
* Support `ClassPrivateProperty`

* Add changelog

* Code style

* Fix babel

* Move logic up

* Add tests

* Make test a little bit uglier
2020-01-31 01:51:27 +09:00
fisker Cheung 90128a3a00 Flow: add typing support for the symbol type (#7472)
* Flow: add typing support for the `symbol` type

* Add changelog
2020-01-30 13:08:01 +03:00
Alexander Kachkaev e00ce8c2c8 Change arrowParens to always by default for 2.0 (#7430) 2020-01-29 13:31:25 +02:00
b47f7bae43 RFC: Always add a space after the function keyword (#3903)
* Always add a space after the `function` keyword

* WIP update snapshots

* WIP put generator function asterisk before space

https://github.com/prettier/prettier/issues/3847#issuecomment-363449250

* WIP update snapshots

* Add changelog

* Add tests for anonymouse generator function

* print space between `function` and generator star

* update changelog

* print space between yield and *

Co-authored-by: Joseph Frazier <1212jtraceur@gmail.com>
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-01-20 16:26:47 +02:00
Misha KaletskyandGeorgii Dolzhykov 911fe7776e method chain breaking heuristic (#6685)
* examples from various issues about method chaining

this commit includes no prettier functionality changes, so that diffs will be easily visible.

specifically:

* https://github.com/prettier/prettier/issues/4125
* https://github.com/prettier/prettier/pull/4765
* https://github.com/prettier/prettier/issues/1565
* https://github.com/prettier/prettier/issues/3107

* add heuristic for breaking method chains

* fix: remove unnecessary escape characters

* initial non-regex isSimple implementation

* handle babel literal types properly

found here: https://github.com/babel/babel/blob/fe258dec047f473fb5a35172b2ff8cb172051dec/packages/babel-parser/ast/spec.md

* template literal + test

* use !every instead of some(!)

* fix: some test cases

* fix: object expressions and some more simple node types

* some test cases showing need for depth check

* depth check

* update test to test thing it's supposed to test

* optional expressions

* test case for missing isSimple depth

* fix isSimple depth bug

* fix: comment check

* test for ts non-null operator

* make object properties behave similarly to arrays

* isSimple -> isSimpleCallArgument; move to utils; add unaries

* add Import to the list of simple things

* only short regexps to be considered simple (<= 5 chars)

* add changelog entry in the new format

* update snapshots

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-01-10 18:00:23 +02:00
fisker Cheung 791996df7b Set trailingComma default value to es5 (#6963)
* Set `trailingComma` default value to `es5`

* Update `options` documentation

* Update tests

* style

* fix js code style

* change options order

* update tests_integration snap

* disable es5 for __ng_interpolation

* fix angular tests

* fix scss test

* fix `css_trailing_comma` snap

* fix css_scss snapshot
2019-11-18 11:39:12 +01:00
Sosuke Suzuki f207e665bc JavaScript: Break arrays of arrays/objects if each element has more than one element/property (#6694)
* Modify to define isJestEachFunctionCall

* Modify to break ArrayExpression when parent is jest each function

* Add tests

* Update CHANGELOG.unreleased.md

* Fix comment

* Add pr number

* Update CHANGELOG.unreleased.md

* Remove hasNewLineInRange

* Modify to change logic for breaking jest each call function

* Modify to add logic for breaking ArrayExpression

* Modify to avoid mixed nested array

* Modify to remove changes for jest

* Update CHANGELOG.unreleased.md

* Update CHANGELOG.unreleased.md
2019-10-25 19:12:07 +03:00
Kevin Gibbons 1e471a0079 Add parentheses for immediately-constructed fn/class (#5996) 2019-03-28 21:06:39 +03:00
Wei-Wei Wu 91c20f7fbe Rename "babylon" with "babel" (#5647) 2018-12-27 21:05:19 +08:00
Ika 952bc0cc03 fix: get rid of CRLF (#5494) 2018-12-08 18:28:29 +08:00
Ika 4af3dd4b07 test: improve snapshots (#5521)
- before
  ```
  ${input}${"~".repeat(printWidth)}
  ${output}
  ```
- after
  ```
  ===options===
  ${options}
  ${" ".repeat(printWidth)}| printWidth
  ====input====
  ${input}
  ===output====
  ${output}
  =============
  ```
2018-11-25 16:21:14 +08:00
Ika 6cedf7d5d9 fix(flow,ts): consistent interface and remove unnecessary indent for extends (#5432) 2018-11-11 00:15:18 +08:00
Jed Fox 65b2454dd8 Improved object-break heuristic (#5205) 2018-10-12 12:45:30 -04:00
Simen Bekkhus 51b7c02e12 Upgrade jest to 22 (#4782)
* chore: upgrade Jest

* chore: update snapshots

* chore: lock down babel dependency using invalid syntax

* 2 args to test.skip

* use jest 22 for now

* Revert "2 args to test.skip"

This reverts commit 691fdc3f99e320f2303958f2b503f7b4c93fa455.

* remove snapshot name from matcher

* fix standalone tests skips
2018-07-03 03:06:29 -03:00
Brian Ng e22ec0b9b9 Bump flow to 0.70 2018-04-16 20:53:07 -05:00
Lucas Duailibe fa089f5bb6 If consequent is a block statement, treat as trailing comment 2018-04-05 17:22:10 -03:00
Lucas Duailibe 88489a9afe Handle comments before else 2018-04-05 16:06:18 -03:00
Brian Ng a8fe401b26 Fix cases with missing semi when printing DeclareExportDeclaration (#3979) 2018-02-17 17:40:43 +11:00
Christopher Chedeau 9ba0d69cb9 Upgrade flow to 0.64 (#3899)
* Upgrade flow to 0.64

This also enables spread operator on jsx on the flow parser:

```js
<div>{...list}</div>
```

I had no idea it was even a thing.

I had to comment out a flow test that no longer parses, but it's no longer in the flow repo and the comment said that it shouldn't be working anyway so I don't think it's going to be a problem.

* Fix build script
2018-02-06 09:01:58 -08:00
Thorben von Hacht 1a1de60491 Prettier extends and implements when not fitting in same line (#3689)
* Added prettier layout for class extends and implements

* Added prettier layout for class extends and implements, fix with keeping it in online if it fits

* Added prettier layout for class extends and implements, fixed tests as a side change

* Extends implements comments in same line fix

* Extends implements comments in same line without ugly workaround

* added empty line to test typescript_class/extends_implements.ts

* If only one extends keep old behaviour

* Removed console logs
2018-01-13 16:31:51 +11:00