-
Notifications
You must be signed in to change notification settings - Fork 653
feat(rome_analyze): emit syntax error diagnostics for suppression comments #3847
Conversation
✅ Deploy Preview for docs-rometools ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
@@ -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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
e18ce14
to
5238ed1
Compare
There was a problem hiding this 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
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 soROME_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 inrome_js_analyze