AdguardTeam / AGLint

Universal adblock filter list linter
https://www.npmjs.com/package/@adguard/aglint
MIT License
49 stars 3 forks source link

Add a new rule to blacklist rules #214

Closed Yuki2718 closed 2 weeks ago

Yuki2718 commented 3 weeks ago

There have been cases a problematic rule was removed and then readded, causing the trouble again. A recent example is https://github.com/AdguardTeam/AdguardFilters/commit/dea5d96863cf30ad6f109ec60b55a598403b25aa but there were many more. I knew the rule would be readded, hence left a comment but it didn't prevent. While other repos such as EL also suffer this sort of issue, it tends to happen on AG more as the number of people working is the largest with some members not being aware of removel of the problematic rule. Adding a blacklist to check before commit will mitigate the problem, e.g. register staff-start.com/js/track/ and any rule including staff-start.com/js/track/ will be warned.

Yuki2718 commented 3 weeks ago

FWIW a similar case in EL: ||static.lefigaro.fr/figconsent/ was removed for https://github.com/easylist/easylist/issues/16487 and then readded by https://github.com/easylist/easylist/pull/18154 , caused https://github.com/uBlockOrigin/uAssets/discussions/25030#discussioncomment-10439394

scripthunter7 commented 2 weeks ago

There are two options here:

Yuki2718 commented 2 weeks ago
  • one is to accept the regexps and blacklist all rules that match these regexps, and

This will be preferred. My idea is that like :contains() plaintext string matches any rules which include the string and regex for more complex cases (e.g. blacklisting only a generic hiding rule and not its specific form). I think the exclusion in FiltersRegistry works in this way?

scripthunter7 commented 2 weeks ago

@Yuki2718 i mean, we can add both)

We can specify the config like this (.aglintrc.yaml)

root: true
extends:
  - aglint:recommended
syntax:
  - AdGuard
rules:
  no-excluded-rules:
    # exclude all rules that match at least one pattern from here
    exclude-patterns:
      - /regex/
    # exclude all rules listed here (character correct match)
    exclude-rules:
      - '||example.com/donotblock.css'
      - '/donotblock.js'

btw, we can extend this with exclude-domains, etc. if ever needed