WIP Implement suppression of plugin diagnostics #4667 #4720
Replies: 3 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.
-
This doc discuss changes related to Implement suppression of plugin diagnostics #4667
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.I assume that we should keep category static and predefined, so to handle dynamic plugin name, we can:
choice 1. add new slot for dynamic subcategory, in which we can put the plugin-name
change syntax to
{ <category> { [<dynamic-subcategory>] }? { (<value>) }? }+: <reason>
,e.g.
// biome-ignore plugin[my-plugin](v) reason to ignore
=>{[{category: "plugin", dynamic_subcategory: "my-plugin", value: "v"}], reason: "reason to ignore"}
in this case will make change to
parse_suppression_line
methodchoice 2. start with
biome-ignore-plugin
, then use custom syntax to parsecustom syntax for plugin:
{ <plugin-name> { (<value>) }? }+: <reason>
e.g.
// biome-ignore-plugin my-plugin my-plugin-2(v) reason to ignore
=>{[{category: "plugin", plugin_name: "my-plugin"}, {category:"plugin", plugin_name: "my-plugin-2", value: "v"}], reason: "reason to ignore"}
int this case, will parse with new method if prefix with 'biome-ignore-plugin'
Personally I think should go with choice 1 because it's less hacky and ad-hoc and work with other suppressions.
Step 2: Generate SuppressionKind from
{category, value}
after getting
{category, value}
, generate corresponding SuppressionKind, defined at crates/biome_analyze/src/lib.rsTask 2
for this step, need to transform the info got from previous step into SuppressionKind
Step 3: Ignore signal by SuppressionKind
in
crates/biome_analyze/src/lib.rs
, athandle_comment
method, it transform SuppressionKind to LineSuppressionthen at flush_matches method, when handling each signal, it try to find a LineSuppression that match the signal by line_index, text_range and suppress filters, if match, the signal is suppressed.
Task 3
add a new suppress filter
for SuppressionKind::Plugin and SuppressionKind::PluginInstance, create LineSuppression with suppressed_plugins field accordingly
then at
flush_matches
, in the matching process, if any plugin insuppressed_plugins
equals to the signal's plugin field, can ignore the signal.TODO: check what does a signal raised from plugin looks like
Beta Was this translation helpful? Give feedback.
All reactions