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

feat(rome_json_formatter): Enable JSON formatting for debug builds #3859

Merged
merged 5 commits into from
Nov 30, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Nov 25, 2022

Summary

This PR enables the formatting capability for JSON for debug builds.

Enabling the JSON formatter for debug builds is useful to integrate it into the prettier test suite (that uses App) and to test rome locally.

Why not rome_flags.is_unstable: We may want to use the unstable flag shortly when at least some formatting is implemented. However, the formatter isn't doing any formatting yet.

Test Plan

  • Ran rome format rome.json in the root directory: Rome reports that the file has been formatted
  • Ran rome check rome.json: Rome emits a diagnostic that linting isn't supported
  • Ran rome ci rome.json: Rome reports that it checked one file
  • Running any of the above commands in release mode reports that the file type isn't supported

Base automatically changed from feat/json_formatter_crate to main November 25, 2022 17:35
@MichaReiser MichaReiser force-pushed the feat/enable-json-formatting-in-debug branch from 3e033ef to 6d32d2e Compare November 28, 2022 15:50
@netlify
Copy link

netlify bot commented Nov 28, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 1c28444
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/638603bde2730f0009980f24

@MichaReiser MichaReiser force-pushed the feat/enable-json-formatting-in-debug branch from 6d32d2e to 54950eb Compare November 28, 2022 16:41
@@ -372,44 +375,57 @@ impl Workspace for WorkspaceServer {
&self,
params: PullDiagnosticsParams,
) -> Result<PullDiagnosticsResult, RomeError> {
let capabilities = self.get_capabilities(&params.path);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change the pull_diagnostics implementation to return the parse diagnostics if linting isn't supported instead of emitting an "unsupported" error.

Not sure if the way I did it is the "best".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd still want to use the lint function, even when the actual linter is disabled. When the linter is disabled, you'd need to create the AnalysisFilter with categories: RuleCategories::SYNTAX instead.

This is necessary because we could have analyzers that work at syntax level. An example is noSuperWithoutExtends

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would I call into the lint function if it is None? It isn't testing if the linter is disabled, it is testing if the language supports linting.

My understanding is that self.get_capabilities returns the capabilities of the language, which is always Some for languages that support linting and only is None for JSON unrelated if the linter is enabled or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there's a slight mismatch between "capabilities" and "features": what the lint capability actually represents is whether we have a rome_<lang>_analyze crate for this language (this includes syntax rules, lint rules and assist rules), and not just whether we support linting for this language

@MichaReiser MichaReiser force-pushed the feat/enable-json-formatting-in-debug branch from 035c750 to 9ab6592 Compare November 28, 2022 16:58
@MichaReiser MichaReiser marked this pull request as ready for review November 28, 2022 17:09
@MichaReiser MichaReiser requested review from leops, ematipico and a team as code owners November 28, 2022 17:09
@calibre-analytics
Copy link

calibre-analytics bot commented Nov 28, 2022

Comparing feat(rome_json_formatter): Enable JSON formatting for debug builds Snapshot #3 to median since last deploy of rome.tools.

LCP? CLS? TBT?
Overall
Median across all pages and test profiles
2.47s
from 281ms
0.0
no change
478ms
no change
Chrome Desktop
Chrome Desktop • Cable
2.47s
from 281ms
0.0
no change
613ms
from 4ms
iPhone, 4G LTE
iPhone 12 • 4G LTE
1.06s
from 246ms
0.0
no change
14ms
no change
Motorola Moto G Power, 3G connection
Motorola Moto G Power • Regular 3G
17.2s
from 1.06s
0.0
no change
478ms
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
Total Blocking Time
Chrome Desktop
613ms
from 4ms
JS Parse & Compile
Motorola Moto G Power, 3G connection
2.18s
from 25ms
Total JavaScript Size in Bytes
Chrome Desktop
5.37 MB
from 86.8 KB
Total JavaScript Size in Bytes
iPhone, 4G LTE
5.37 MB
from 86.8 KB
Total JavaScript Size in Bytes
Motorola Moto G Power, 3G connection
5.37 MB
from 86.8 KB

27 other significant changes: JS Parse & Compile on iPhone, 4G LTE, JS Parse & Compile 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 Chrome Desktop, Number of Requests on Motorola Moto G Power, 3G connection, 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

@MichaReiser MichaReiser added the A-CLI Area: CLI label Nov 29, 2022
@MichaReiser
Copy link
Contributor Author

I created a json field on the settings.

@MichaReiser MichaReiser merged commit 519df0b into main Nov 30, 2022
@MichaReiser MichaReiser deleted the feat/enable-json-formatting-in-debug branch November 30, 2022 15:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-CLI Area: CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载