Commit Graph

25 Commits (master)

Author SHA1 Message Date
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
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
Karl O'Keeffe 7a3ac3a693
Handle JSX whitespace separately from fbt whitespace (#4717)
* Hande JSX whitespace separately from fbt whitespace

* Extra test cases

* Further tweak to JSX handling

* Possible improvement of single character text

* More tests

* Pull out separator code

* More tests for fbt
2018-06-25 19:11:40 +01:00
Lucas Duailibe f119d4a90f
Change run_spec to have explicit parser list (#3356) 2017-11-30 03:31:52 -03:00
Stephen Scott 3ed2bae1b4 Improve JSX ternary formatting
* Now JSX-mode ternaries only break if they need to. 
* Only the outermost ternary in a chain of JSX-mode ternaries will become a group.
* We don't wrap null in parens when breaking JSX-mode ternaries.

This commit also improves the test coverage and explanation in tests/jsx/conditional-expression.js.
2017-07-13 10:21:58 -06:00
Stephen Scott 757037948a Improve JSX Formatting
* Arrow Function Expressions returning JSX will now add parens when the JSX breaks
* Conditional expressions within (or containing) JSX are formatted in a more natural way (for JSX), especiall when chained
* JSX in logical expressions (|| or &&) is always wrapped in parens

Fixes #2208
2017-07-13 10:20:42 -06:00
Karl O'Keeffe 5e76ea7bdd Allow single expressions in JSX to be inline 2017-07-10 20:02:30 +01:00
Karl O'Keeffe 06ae32ddce Ensure there is a line break after leading JSX white space (#2348) 2017-07-03 12:43:10 +02:00
Karl O'Keeffe be600337eb Improve JSX output when there is a single expression (#2274) 2017-06-26 19:05:34 -07:00
Karl O'Keeffe 95a5f11be9 Tweak to support FB translation pipeline (#2272)
This also improves formatting when there are consecutive tag/expression elements with no white space between them.
2017-06-26 09:30:52 -07:00
Karl O'Keeffe 0cc0ebc3bc Allow JSX lines to be recombined (#1831)
* Allow JSX lines to be recombined

* Add test case for `<br />` breaking expression

* Fix issue where JSX whitespace could be dropped

* Newlines were incorrectly being preserved when JSX contained text
2017-06-22 09:19:44 -07:00
Karl O'Keeffe 73432c2ce7 Position JSX whitespace (`{" "}`) at the end of lines (#1964)
* Position JSX whitespace at the end of lines

Currently we place JSX whitespace at the beginning of lines.

* Use `isLiteral` when determining JSX whitespace
2017-06-05 21:52:54 +01:00
Karl O'Keeffe f4ef1c2c97 JSX whitespace on the same line as text (#1829)
This tweaks our JSX formatting to only put a JSX whitespace `{" "}` on a line by itself when it comes before or after a multiline element.

When preceding a text or single line element it appear on the same line as that element.
2017-05-31 10:16:50 -07:00
Christopher Chedeau ffc1b3702e Remove parenthesis for JSX inside of arrow functions (#1733)
I didn't intend for putting parenthesis there in the first place but it slept through. Since it was going to trigger a ton of changes I held up changing it, but I feel like we need to do it sooner than later otherwise we're not going to be able to do it. A lot of people writing functional components are going to be very happy about this change :)
2017-05-25 16:26:49 -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
ChristianHersevoort 04c959d687 Feature/verify against same snapshot (#1087)
* Verify parsers against same snapshot

- Reworked run_spec, now accepts 3th optional array argument for
additional parsers to verify against
- Merged duplicate run_spec configs
- Removed duplicate snapshot data

* Formatted run_spec.js with prettier

* Fixed node4 incompatibility
2017-03-25 08:10:17 -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
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
Christopher Chedeau 2ea1dbcb6a Fix indentation of a merged group (#828)
Printing a merged group indented was actually not the right fix. The right fix was to print them in a single line. It used to have this behavior when I was mutating the first group but now that I don't anymore I need to reproduce this condition.

Fixes #823
2017-02-28 10:55:32 -05:00
Christopher Chedeau c84027745b Add `this` for Member factory whitelist and remove softline (#782)
In addition to Observable, $ or _, we should also add `this` to the list of things that are likely factory and not objects you want to apply things on directly.

I added a way to make the function call break on its own line when it doesn't fit in one line and indent. But I think that only having the indentation is enough, having the call on its own line feels weird.

Fixes #777
2017-02-23 09:41:44 -05: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
Alex Rattray 72c9424c53 Indent ternaries (#484) 2017-01-26 11:58:40 -08:00
Christopher Chedeau 573936aacc [RFC] Hug Conditionals in JSX (#473)
Conditionals are very common in JSX and it is unfortunate that they take up so much vertical space in the current prettier.

This pull request does a few tweaks:
 - It hugs ConditionalExpression (ternary) and LogicalExpression (&&) inside of `{}` in a jsx child, not an attribute
 - It doesn't output parenthesis if your parent is a LogicalExpression (&&)

Fixes #317
2017-01-26 14:51:08 -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