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

fix(rome_cli): do not print lint warnings for the format command #2680

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Jun 8, 2022

Summary

This PR fixes #2670 by skipping the printing of diagnostics in traversal operations for the format commands if no errors were returned by pull_diagnostics
Additionally, I exposed the categories filter from rome_analyze to consumers of the pull_diagnostics method to let clients chose which diagnostics categories they want: in format mode this is used to only run rules with the SYNTAX category and ignore LINT rules, to avoid emitting diagnostics that would not impact the correctness of formatting in the first place

Test Plan

I added an additional lint_warning test to the CLI verifying no warnings are printed to the console when formatting files with lint errors

@leops leops temporarily deployed to aws June 8, 2022 08:46 Inactive
@github-actions
Copy link

github-actions bot commented Jun 8, 2022

Comment on lines +97 to +100
let diagnostics = self.workspace.pull_diagnostics(PullDiagnosticsParams {
path: rome_path,
categories: RuleCategories::SYNTAX | RuleCategories::LINT,
})?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: What do you think of having a new function that only accepts the path and defaults the categories to all categories and a method with_categories that changes the categories to the specified categories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now I think it's alright to explicitly set all parameters while there are only a few of them, but it would make sense to introduce such a builder pattern if these methods need additional options (and they probably will as the analyzer starts getting more features)

@leops leops merged commit 9771563 into main Jun 8, 2022
@leops leops deleted the fix/cli-format-warning branch June 8, 2022 09: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.

🐛 rome format shouldn't emit lint warnings
2 participants