-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add formatter option to the VSCode extension #98
Comments
I see two main ways of implementation:
A while ago I collected a basic concept for the rule orderer. You can find it here: https://github.com/scripthunter7/adblock-rule-orderer I would separate the following steps:
I also thought about grouping the rules by websites, but what should happen if a filtering rule contains several different domains? For example: example.com,example.net###banner
/script-to-block.js^$script,domain=example.com|example.org|~example.net or if one rule belongs to the scope of a preprocessor directive, while the others don't: example.com###banner-1
example.com###banner-2
!#if (adguard_ext_safari || adguard_app_ios || adguard_ext_android_cb)
@@/script-to-block^$script,domain=example.com
! ...
! other rules
!#endif Should these rules be moved to some kind of mixed category? |
We also should consider to keep the formatting in sync with the planned code guidelines: AdguardTeam/CodeGuidelines#16 |
Not clear how to resolve cases when one comment is related to a group of rules |
@maximtop we can provide special rules for that, something like this:
|
If we introduce such rules, perhaps it would make sense to follow the pattern of preprocessor directives:
|
IMO, formatter and linter are different things and mixing them together may be confusing. At the same time, it does not mean that AGLint cannot enforce formatting rules, it can rely on the formatter for that. |
After all, AGTree is the basis, linter and formatter can also be built on it. It is important to divide the formatter into two categories:
Separate config schemas should be prepared for both categories. |
We use this approach for some sites. In general it is not a good idea to apply it for all rules, because some rules can be applied to many sites, they can have mirrors (not only with different TLD), and they merged into one large rule.
In some cases we are using Comment Anchors to improve file navigation
Automatically creating groups will not improve convenience. |
The problem with the current structure in AdguardFilters is that it's hard to understand where to add a new rule unless you already have lots of experience working with it. I don't think we should take it as an example. Instead of that, let's think what structure would be reasonable to use if we were creating a new list from scratch. |
@ameshkov ESLint also drops formatting rules: https://eslint.org/blog/2023/10/deprecating-formatting-rules/ |
At this point this is an issue for discussing how the formatter can be implemented and how exactly the filter lists and individual rules should be formatted / sorted.
My initial idea is to sort the filter lists so that all rules for a given website were collected together. Something like this:
At the same time we should take comments into account. Maybe allow grouping rules into a single section using special comments.
Anyways, lets discuss.
CC @AdguardTeam/filters-maintainers @maximtop @scripthunter7
The text was updated successfully, but these errors were encountered: