Commit Graph

44 Commits (master)

Author SHA1 Message Date
fisker Cheung 179943ccba Update `@babel/parser` to v7.6.3 (#6386)
* fix flow_function_parentheses

* fix directives

* fix classes

* fix flow_method

* fix `do`

* fix `decorators`

* fix `comments_closure_typecast`

* fix `comments`

* fix `flow_internal_slot`

* fix `flow_comments`

* fix `flow_type_declarations`

* fix `flow_type_spread`

* fix `functional_composition`

* fix `multiparser_js_css`

* fix `no-semi`

* fix `objects`

* fix `template`

* fix `yield`

* update `flow_method` snap

* fix `empty_paren_comment`

* fix `mdx`

* fix `object_property_comment`

* Update `@babel/parser`

* Update @babel/parser to v7.6.2

* Update yarn.lock

* fix `nullish_coalescing` test

* fix `flow_class_field` test

* fix snapshot

* @babel/parser v7.6.3

* fix tests

* update snap
2019-10-09 14:52:11 +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 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 da91fb2f46
fix(javascript): allow top level super and await (#4823) 2018-07-11 13:18:20 +08: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
Nicolò Ribaudo ab452ddc38 Fix: Correctly break class prperties initializer. (#4442) 2018-05-08 20:35:49 -04:00
Lucas Duailibe 41098a06b5
Prevent "over-indenting" class properties values (#4085) 2018-03-02 11:28:27 -03: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
Lucas Duailibe f119d4a90f
Change run_spec to have explicit parser list (#3356) 2017-11-30 03:31:52 -03:00
Lucas Azzola bff28023b3 Comments: attach method name comments with estree parsers, fixes #2141 (#2170) 2017-06-17 22:22:39 +10:00
Christopher Chedeau 73ff0ef9ea Add group around implements (#1821)
This shouldn't break if it fits in one line.

Fixes #1818
2017-05-30 09:45:07 -07:00
Lucas Azzola 2a58e6bc06 test(typescript): enable typescript-verify on most tests (#1781) 2017-05-27 17:57:07 -07:00
Christopher Chedeau d06c46d045 Break on implements instead of extends (#1730)
There can often be something that breaks inside of `extends` so it's looking weird to break twice. It now only breaks on `implements` and make sure to put each element on its own line.

Fixes #1520
2017-05-25 16:26:56 -07:00
Jan Kassens b82220b20f Prittier printing of snapshots (#1190)
This uses a custom snapshot serializer to reduce escaping in snapshot files and
make them easier to read.

Snapshot serializers are documented here:
https://facebook.github.io/jest/docs/configuration.html#snapshotserializers-array-string
2017-04-12 13:41:51 -07:00
Christopher Chedeau c3199359b0 Revert "Improve snapshot naming" (#1070)
* Revert "Remove mutation in `printBinaryishExpressions` (#1067)"

This reverts commit e7312ad7b2.

* Revert "Make it clear what parser was used in each snapshot (#1068)"

This reverts commit 4f7ae4815b.
2017-03-21 17:38:28 -07:00
ChristianHersevoort 4f7ae4815b Make it clear what parser was used in each snapshot (#1068) 2017-03-21 14:47:23 -07: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
Rogelio Guzman d45e157563 Upgrade to Jest 19 (#762)
* Upgrade to Jest 19

* Use exact versions for Jest
2017-02-21 13:59:19 -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 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 3b66af3d60 Remove the concept of globalPrecedingNode (#561)
The original motivation for this change is trying to fix #560 where the comment was attached to the JSXText node instead of the JSXExpressionContainer because it used the globalPrecedingNode. In general, I don't think that it is very safe to attach a comment to a random node just because it happened to be before.

I tried to delete the globalPrecedingNode codepath and I think that it actually improves the results. I'll add inline comments in the pull request to explain the various changes.

Fixes #560
2017-02-03 13:56:06 -08:00
Christopher Chedeau 57ab92ed33 Support dangling comments in ClassBody (#570)
Comments were dropped there
2017-02-03 16:16:32 -05:00
Christopher Chedeau 620cb7be19 Add break points for class declaration (#466)
```js
class A extends B implements C {
  method() {}
}
```

now outputs

```js
class A
  extends B
  implements C {
  method() {}
}
```

Fixes #147
2017-01-25 16:36:55 -05:00
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00
Christopher Chedeau fb52e7a5c8 Do not put a newline on empty `{}` for functions (#447)
The original intent of it was for `if then else` and `try catch` as they aren't likely to be empty, but it accidentally caught function bodys, which have many valid reasons to be empty. Let's special case those out.
2017-01-24 12:37:01 -05:00
Christopher Chedeau d7a44bae10 Add parenthesis when class expressions are left of a ternary (#428)
Fixes #426
2017-01-22 20:32:17 -08:00
Christopher Chedeau b13124bed4 Add parenthesis for class expression on left of member expression (#421)
Fixes #414
2017-01-22 19:05:46 -08:00
Christopher Chedeau 105a164423 Add parenthesis around class expression when left side of call expression (#409)
Fixes #402
2017-01-22 16:22:49 -08:00
Christopher Chedeau b77703a942 Fix class inside of binary expression missing parenthesis (#397)
Fixes #395
2017-01-22 14:33:04 -08:00
Christopher Chedeau 789a3029f4 Remove +1 from newline detection (#261)
* Remove +1 from newline detection

All the changes are related to spurious `;`. Sometimes the logic is more correct, sometimes less. Since `;` are going to be removed after the first save, I don't think it matters that much.

* Handle inconsistent `end` node locations when looking for newlines
2017-01-17 22:33:55 -05:00
Christopher Chedeau 74bc9e7a4d Add newline for empty blocks {} (#205)
I find it weird to put `{}` together. So I figured I would change it to have an empty line and ask for feedback :)

![image](https://cloud.githubusercontent.com/assets/197597/21739279/062adc80-d44c-11e6-8bb7-5e0768f3ddde.png)

Beware: most of the test cases are not representative of real code, you almost never define blocks with no content in practice.
2017-01-16 11:31:32 -05:00
James Long 00fad62c91 Regenerate snapshots 2017-01-11 10:16:38 -05:00
James Long d2d6def9be Revert "fixes #49: omit new parens when it has no arguments"
This reverts commit b5392f9468.
2017-01-10 18:53:03 -05:00
Michael Ficarra b5392f9468 fixes #49: omit new parens when it has no arguments 2017-01-10 11:14:39 -08:00
James Long a4643f1bae Add special case for comment at top of file; regenerate snapshots 2017-01-09 21:49:26 -05:00
James Long bcd44b4368 Keep blank lines from original source 2017-01-09 09:46:09 -05:00
James Long b550f1d088 Use , to separate type fields instead of ; 2017-01-04 17:26:44 -05:00
James Long 37601b0a86 Update snapshots 2017-01-01 20:20:45 -05:00
James Long c9e24eb477 Add spaces around certain statements, add --write option, and more 2016-12-30 23:01:07 -05:00
James Long 6715abca76 Tweak variable declaration printing 2016-12-30 11:56:42 -05:00
James Long 11a01552a4 Lots of bug fixes (will do smaller commits from now on) 2016-12-30 00:01:44 -05:00
James Long 9acd34d67d update snapshots 2016-12-27 13:29:31 -05:00
Christopher Chedeau cf45afba61 Add testing
- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases
- This creates snapshot tests using the pretty printer for all of them
- If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
2016-12-23 19:51:53 +00:00