Implement suppression of plugin diagnostics #4667 #4720
Replies: 4 comments
-
Thanks for the clear write-up! Task 1You make a good observation that we'll need a dynamic subcategory. So the static category can remain The reason why I'd suggest doing it this way is because I would try to avoid leaking the implementation details of static vs. dynamic categories to the user. If we introduce a special syntax for this, it just adds confusion: Why another syntax? Why can't it work like other categories? We'd have no way to explain the rationale without explaining the implementation. Task 2I don't think we'll need Task 3Sounds good to me! 🚀 PS.: Maybe @ematipico also has some insights here that I might've missed. |
Beta Was this translation helpful? Give feedback.
-
That's not technically correct. That file contains is there only to create a macro called Under the hoods, categories can be whatever we want. Regarding task 3, there's no need for a new suppression kind I think, because plugins aren't going to introduce a new variant of |
Beta Was this translation helpful? Give feedback.
-
Thanks for helping review! I will fix the errors and finalize details in this doc soon and start the implementation 🤝 |
Beta Was this translation helpful? Give feedback.
-
Sorry for the long delay. I have finished a basic implementation for suppress plugin. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This doc discuss changes related to Implement suppression of plugin diagnostics #4667
syntax
current implementation use
// biome-ignore lint/plugin/myCustomPlugin: <reason>
.Implementation
See More
I'm new to biome and open source, please forgive any naive from my side. 🙇♂️
Below I list how suppression comment works in biome and possible changes need to make for #4667
Step 1: Parse suppression comment to
{[{ category, value }], reason}
The parser for comments is at `/crates/biome_suppression/src/lib.rs``
For each comment line that starts with 'biome-ignore', parse by syntax
{ <category> { (<value>) }? }+: <reason>
and return{ [ { category, value } ], reason}
For example, with comment
// biome-ignore lint/a11y/noAccessKey(v) some reason for ignoring
Return
{[{category="lint/a11y/noAccessKey", value="v"}], reason="some reason for ignoring"}
All categories are prebuild and defined in
crates/biome_diagnostics_categories/src/categories.rs
. if not included, will cause parse fail.Task 1:
The initial proposed format to suppress plugin diagnostics is
// biome-ignore plugin/<plugin-name> <reason>
category part is
plugin/<plugin-name>
, it's dynamic, we don't know the plugin-name at build time.To handle this, we need to add ad-hoc logic to category parsing if category starts with
plugin/
to get dynamic subcategory value.Step 2: Generate AnalyzerSuppression from
(category, subcategory, value)
after getting
(category, subcategory, value)
, generate corresponding AnalyzerSuppression, defined at crates/biome_analyze/src/lib.rsTask 2
Implement above changes
Step 3: Ignore signal by AnalyzerSuppression
in
crates/biome_analyze/src/lib.rs
, athandle_comment
method, it parse comment to AnalyzerSuppression and store them asTopLevelSuppression, LineSuppression and RangeSuppression
.then at flush_matches method, when handling each signal, it try to find a suppression that match the signal by line_index, text_range and suppress filters, if match, the signal is suppressed.
Task 3
Plugins are run after exiting lint runners are finished, we need to match and suppress diagnosis.
crates/biome_analyze/src/lib.rs Analyzer::run
)Beta Was this translation helpful? Give feedback.
All reactions