protolint icon indicating copy to clipboard operation
protolint copied to clipboard

Exclude directories via pattern

Open Kresshy opened this issue 2 years ago • 4 comments

Is it possible to exclude directories from the linter via a pattern? Something like a glob: **/build which would match every build directory from the root to other sub directories.

lint:
  rules:
    all_default: true

  directories:
    exclude:
      - **/build

Kresshy avatar Sep 19 '23 23:09 Kresshy

@Kresshy Sorry for the late response. At the moment, this feature is not supported. I acknowledge that this feature could be worthwhile.

yoheimuta avatar Oct 01 '23 01:10 yoheimuta

+1 for this feature, would be very useful to exclude linting on proto files imported from external repositories that we don't have/want control over.

brentru avatar Dec 12 '23 15:12 brentru

@yoheimuta Thanks for this nice utility. I am interested in contributing this feature.

Do you prefer pattern matching via glob as suggested in this issue, or regex? In my opinion globs are nicer to work with, but the standard library implementation in filepath doesn't support the ** pattern which many users will expect to be supported. There are third-party libraries such as https://github.com/bmatcuk/doublestar that could be used instead.

For backwards-compatibility reasons I think we'd have to introduce a new field (exclude_pattern ?) for both directories and files.

stevenschaerer avatar Mar 11 '24 14:03 stevenschaerer

@stevenschaerer Thanks for the suggestion! I can see the appeal of globs for some users, so adding support for them seems like a great idea.

I also like the idea of introducing a new field.

yoheimuta avatar Mar 12 '24 01:03 yoheimuta