AdguardTeam / AGLint

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

Improve compatibility table checker #125

Closed scripthunter7 closed 1 year ago

scripthunter7 commented 1 year ago

This PR adds detailed validation of the value_format field to the compatibility table validator script, and also allows detection of invalid regular expressions

I installed the xregexp package, because as far as I know, the plain JS regex doesn't support free-space mode, which is the easiest way to handle regexps represented in YML in multiple lines + we can write comments inside the regexps like this:

adg_os_any:
  name: removeheader
  # Enable free-spacing and case-insensitive mode for the regex
  value_format: |-
    (?xi)
      ^
        # Value may start with "request:"
        (request:)?

        # Forbidden header names
        (?!
          (
            access-control-allow-origin|
            access-control-allow-credentials|
            access-control-allow-headers|
            # ...
          )
        $)

        # Any other header name is allowed, if it matches the following regex
        [A-z0-9-]+
      $
  inverse_conflicts: true