Skip to content

Feature Request: Regex lists #2250

Description

@Repiteo

Seeing as this project is already diverging from pre-commit on several foundational levels, I want to propose an addition that is no longer planned for the OG project: regex lists. This functionality was originally considered for the pre-commit project1, but was ultimately shelved for concerns of mixed syntax. Seeing how far tools like intellisense and schema validation has come in that time, as well as list support already being integrated for the prek-exclusive glob patterns, I think it warrants revisiting.

This would most prominently replace verbose regex, which often doesn't play nice with version control:

exclude = '''(?x)(
  ^thirdparty/|
  -(dll|dylib|so)_wrap\.[ch]$|
  ^platform/android/java/editor/src/main/java/com/android/|
  ^platform/android/java/lib/src/main/java/com/google/
)'''

The above syntax could instead be implemented as:

exclude = [
  "^thirdparty/",
  '-(dll|dylib|so)_wrap\.[ch]$',
  "^platform/android/java/editor/src/main/java/com/android/",
  "^platform/android/java/lib/src/main/java/com/google/",
]

Footnotes

  1. Support files / exclude as both regex / list of regexes pre-commit/pre-commit#149

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaJust an idea

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions