Commit Graph

24 Commits (master)

Author SHA1 Message Date
Lucas Duailibe eca23e111f
Stop converting empty JSX elements to self-closing elements (#6127)
Co-Authored-By: Simon Lydell <simon.lydell@gmail.com>
2019-05-16 15:14:35 -03: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
Yulia Galuzo 0c7c1bfde4 fix: splitting jsx text correctly (#5006)
Fixes: #4941
2018-09-02 19:59:28 +02: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
Karl O'Keeffe fa83ce3f3f Fix calculation of whether doc parts fit (#3081) 2017-10-22 07:54:23 +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
Christopher Chedeau e707bdd52f Print comments attached to {' '} (#2283)
We had two occurrences on fb codebase where people attached comments on `{' '}` which would be swallowed. Instead of dropping the comments, let's make the algorithm a bit less naive.
2017-06-27 09:35:03 -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
Karl O'Keeffe 5cda955efc New primitive to fill a line with as many doc parts as possible (#1120)
* Add new fill primitive and use it to wrap text in JSX

This adds a new `fill` primitive that can be used to fill lines with as much code as possible before moving to a new line with the same indentation.

It is used here layout JSX children. This gives us nicer wrapping for JSX elements containings lots of text interspersed with tags.

* Quick fix for jsx whitespace regressions

* Fix a couple more bugs

* Tidy up the `fill` algorithm

Attempt to make the algorithm a little more regular, and improve the naming of variables to make it a little easier to understand (I hope!).

* Small tidy up of JSX whitespace declarations

* Remove unnecessary code

It turns out that `children` is only used in the case when the element is printed on a single line, in which case all the types of JSX whitespaces behave the same, so we don't need to special case leading/trailing/solitary whitespace.

* A little more tidy up based on PR feedback

* Fix up tests after rebasing

* Make it explicit that we keep multiple consecutive spaces

* Add an explanatory comment

* Fix broken snapshot in master

* Ignore existing commands when deciding whether content will fit when using fill

* Fix a bug where children would get incorrectly filled onto a line

* Tidy up JSX whitespace names
2017-05-10 16:13:21 -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 f1548e76bd re-run snapshot tests 2017-03-01 09:11:54 -08:00
Alex Rattray aef1ac61c9 [JSX] Break before and after jsx whitespace (#836) 2017-02-28 13:30:54 -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
Alex Rattray 91d4f400a4 [JSX] jsx-whitespace breaks with parent (fixes #622) (#626) 2017-02-07 13:47:34 -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