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

refactor(rome_analyze): align the syntax of lint suppression with the corresponding diagnostic category #3788

Merged
merged 3 commits into from
Nov 21, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Nov 18, 2022

Summary

Fixes #3446

This PR changes the syntax of lint suppression comments from rome-ignore lint(group/rule) to rome-ignore lint/group/rule to align with how lint categories are presented in diagnostics. I've tried to keep backwards compatibility by continuing to parse the previous syntax, and emitting a diagnostic with a safe fix when such a comment is encountered by the linter.

Test Plan

I've extended the suppression comment tests in rome_js_analyze to check that both the new and old syntax remain supported, and that a diagnostic is correctly emitted for the deprecated syntax. Additionally I've also used a local build of the language server to apply the automatic fix to all the files with suppression comments that we have.

@leops leops requested a review from a team November 18, 2022 11:18
@netlify
Copy link

netlify bot commented Nov 18, 2022

Deploy Preview for docs-rometools ready!

Name Link
🔨 Latest commit da9e60c
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/637b815484f9fb00087ac96c
😎 Deploy Preview https://deploy-preview-3788--docs-rometools.netlify.app
📱 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

github-actions bot commented Nov 18, 2022

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%

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.

Could you please add a new snapshot test in the CLI that shows the new diagnostic emitted for old suppression comments?

Comment on lines 505 to 512
let signal = DiagnosticSignal::new(move || {
SuppressionDiagnostic::new(
file_id,
category!("suppressions/deprecatedSyntax"),
range,
"Suppression is using a deprecated syntax",
)
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Here this diagnostics could have the tag DiagnosticTags::DEPRECATED_CODE. It doesn't make much sense to keep two different comment styles and should stick with one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is something I considered doing but I ended up not going with it as it made the editor highlight the suppression comment with the deprecated strike-through styling, this made it seem like the comment itself was deprecated which I thought could be confusing to some users.
suppression_deprecated

}
}
DiagnosticKind::Raw(error) => {
DiagnosticKind::Raw(error.with_tags(DiagnosticTags::FIXABLE))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the final tags joined together with this function? Because diagnostics emitted for old suppression comments should deprecated and fixable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I've implemented the .with_tags combinator to return a new diagnostic that has both the tags of the inner diagnostics in addition to the ones passed in to the function

@leops leops force-pushed the refactor/lint-suppression-syntax branch from a24123d to fc2e2c7 Compare November 18, 2022 15:57
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.

Not a blocker, but I still think that these diagnostics should be tagged as deprecations.

Also, can these warnings block rome ci? If yes, we should demote them to simple info diagnostics. Otherwise, I think we can merge it!

@leops leops added A-Linter Area: linter A-Diagnostic Area: errors and diagnostics labels Nov 21, 2022
@leops leops force-pushed the refactor/lint-suppression-syntax branch from fc2e2c7 to da9e60c Compare November 21, 2022 13:46
@leops
Copy link
Contributor Author

leops commented Nov 21, 2022

Also, can these warnings block rome ci? If yes, we should demote them to simple info diagnostics. Otherwise, I think we can merge it!

Warnings should not cause rome ci to fail, only error-level diagnostics will make the CLI return with a non-zero error code

@leops leops merged commit 26b4f1d into main Nov 21, 2022
@leops leops deleted the refactor/lint-suppression-syntax branch November 21, 2022 14:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Diagnostic Area: errors and diagnostics A-Linter Area: linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule name in ignore comment and diagnostic differ
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载