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

feat(rome_analyze): emit syntax error diagnostics for suppression comments #3847

Merged
merged 4 commits into from
Nov 28, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Nov 24, 2022

Summary

Fixes #3841

With the existing suppression comment parsing logic, any comment that failed to parse as a suppression was simply ignored by the analyzer and formatter. I've modified the signature of the suppression parser so that any comment line that starts with rome-ignore (I've also changed this to be case insensitive and allow underscores so ROME_IGNORE would work too) is now detected as a suppression comment, and everything that comes after must parse correctly or a diagnostic will get emitted.
I expect this change to improve the developer experience of using suppression comments since incorrectly written suppression will now emit an explicit syntax error instead of being silently ignored.

Test Plan

I've added additional tests for the newly introduced errors to both the suppression parser in rome_js_syntax and the overall analyzer infrastructure in rome_js_analyze

@leops leops requested a review from a team November 24, 2022 13:47
@netlify
Copy link

netlify bot commented Nov 24, 2022

Deploy Preview for docs-rometools ready!

Name Link
🔨 Latest commit 8925c02
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/6384dc84b281660009c5e5a0
😎 Deploy Preview https://deploy-preview-3847--docs-rometools.netlify.app/playground
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@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%

@@ -246,10 +249,11 @@ struct LineSuppression {
did_suppress_signal: bool,
}

impl<'a, 'phase, L, Matcher, Break> PhaseRunner<'a, 'phase, L, Matcher, Break>
impl<'a, 'phase, L, Matcher, Break, Diag> PhaseRunner<'a, 'phase, L, Matcher, Break, Diag>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is becoming a beat. Would it be possible to use the boxed diagnostics versions instead of adding another type of argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it's not possible to use a boxed trait here as the diagnostics needs to implement Clone, since the clone() method returns an owned Self it cannot be represented by an unsized dyn Trait

@leops leops force-pushed the feature/suppression-parser-diagnostic branch from e18ce14 to 5238ed1 Compare November 28, 2022 10:40
@leops leops requested a review from a team as a code owner November 28, 2022 10:40
Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Can we add a new CLI test, that shows this new diagnostic? As far as I understood, this change will affect CLI/LSP users, so having user-facing tests would be great

@leops leops merged commit cde61ac into main Nov 28, 2022
@leops leops deleted the feature/suppression-parser-diagnostic branch November 28, 2022 16:22
@ematipico ematipico added this to the 11.0.0 milestone Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

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