+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_json_formatter): Setup JSON Formatter crate #3854

Merged
merged 8 commits into from
Nov 25, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Nov 25, 2022

Summary

This PR sets up the new rome_json_formatter crate with the "default" implementation for all formatters except literals (trivial) and the root.

It adds:

  • The JsonFormatContext and JsonFormatOptions
  • The JsonFormatter
  • The formatters for JsonSyntaxNode and blank implementations for each AST node.
  • It enables json formatting support for debug builds only (There's an issue with the CLI now emitting linting is unsupported for JSON files. I'm going to tackle this in a dedicated PR)

It changes:

  • The visibility of all Format* nodes to pub(crate). These are implementation details and shouldn't be public
  • Extracted the common traits that each formatter has into a traits_shared.rs file in rome_formatter and included it with the include macro in rome_json_formatter and rome_js_formatter

Test Plan

I added a smoke test that calls into the formatter. A next step is to set up integration tests and prettier tests.

@MichaReiser MichaReiser linked an issue Nov 25, 2022 that may be closed by this pull request
3 tasks
@MichaReiser MichaReiser marked this pull request as ready for review November 25, 2022 12:34
@MichaReiser MichaReiser requested review from ematipico and a team as code owners November 25, 2022 12:34
Base automatically changed from feat/json-parser to main November 25, 2022 13:51
@MichaReiser MichaReiser requested a review from leops as a code owner November 25, 2022 13:51
@MichaReiser MichaReiser force-pushed the feat/json_formatter_crate branch from af67515 to 1902119 Compare November 25, 2022 13:56
@netlify
Copy link

netlify bot commented Nov 25, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 52bd3ec
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/6380f029617f230009d8fd36

@calibre-analytics
Copy link

calibre-analytics bot commented Nov 25, 2022

Comparing feat(rome_json_formatter): Setup JSON Formatter crate Snapshot #8 to median since last deploy of rome.tools.

LCP? CLS? TBT?
Overall
Median across all pages and test profiles
2.29s
from 257ms
0.0
no change
142ms
no change
Chrome Desktop
Chrome Desktop • Cable
2.29s
from 257ms
0.0
no change
350ms
from 20ms
iPhone, 4G LTE
iPhone 12 • 4G LTE
1.11s
from 241ms
0.0
no change
17ms
no change
Motorola Moto G Power, 3G connection
Motorola Moto G Power • Regular 3G
16.6s
from 1.07s
0.0
no change
142ms
no change

1 page tested

 Home

Browser previews

Chrome Desktop iPhone, 4G LTE Motorola Moto G Power, 3G connection
Chrome Desktop iPhone, 4G LTE Motorola Moto G Power, 3G connection

Most significant changes

Value Budget
JS Parse & Compile
Motorola Moto G Power, 3G connection
1.71s
from 27ms
Total JavaScript Size in Bytes
Chrome Desktop
5.36 MB
from 86.8 KB
Total JavaScript Size in Bytes
iPhone, 4G LTE
5.36 MB
from 86.8 KB
Total JavaScript Size in Bytes
Motorola Moto G Power, 3G connection
5.36 MB
from 86.8 KB
JS Parse & Compile
iPhone, 4G LTE
484ms
from 11ms

27 other significant changes: JS Parse & Compile on Chrome Desktop, Total Blocking Time on Chrome Desktop, Largest Contentful Paint on Motorola Moto G Power, 3G connection, First Contentful Paint on Motorola Moto G Power, 3G connection, Total CSS Size in Bytes on Chrome Desktop, Total CSS Size in Bytes on iPhone, 4G LTE, Total CSS Size in Bytes on Motorola Moto G Power, 3G connection, Time to Interactive on Motorola Moto G Power, 3G connection, Total Page Size in Bytes on Chrome Desktop, Total Page Size in Bytes on iPhone, 4G LTE, Total Page Size in Bytes on Motorola Moto G Power, 3G connection, Time to Interactive on Chrome Desktop, Largest Contentful Paint on Chrome Desktop, First Contentful Paint on Chrome Desktop, Number of Requests on Motorola Moto G Power, 3G connection, Number of Requests on Chrome Desktop, Number of Requests on iPhone, 4G LTE, Speed Index on Motorola Moto G Power, 3G connection, Time to Interactive on iPhone, 4G LTE, First Contentful Paint on iPhone, 4G LTE, Largest Contentful Paint on iPhone, 4G LTE, Speed Index on Chrome Desktop, Total HTML Size in Bytes on Chrome Desktop, Total HTML Size in Bytes on iPhone, 4G LTE, Total HTML Size in Bytes on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Chrome Desktop

Calibre: Site dashboard | View this PR | Edit settings | View documentation

@github-actions
Copy link

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45879 45879 0
Passed 44936 44936 0
Failed 943 943 0
Panics 0 0 0
Coverage 97.94% 97.94% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5946 5946 0
Passed 1757 1757 0
Failed 4189 4189 0
Panics 0 0 0
Coverage 29.55% 29.55% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12397 12397 0
Failed 3860 3860 0
Panics 0 0 0
Coverage 76.26% 76.26% 0.00%

@MichaReiser
Copy link
Contributor Author

TODO add to benchmark after #3845 lands

@MichaReiser MichaReiser force-pushed the feat/json_formatter_crate branch from 0c705d6 to 52bd3ec Compare November 25, 2022 16:41
@MichaReiser MichaReiser merged commit 3030b4b into main Nov 25, 2022
@MichaReiser MichaReiser deleted the feat/json_formatter_crate branch November 25, 2022 17:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-Lang Formatter: Code Gen Support
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载