mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.69k stars 273 forks source link

Add denyRegex support for import-alias-naming rule #927

Closed denisvmedia closed 8 months ago

denisvmedia commented 8 months ago

This PR provides an extension to the existing import-alias-naming rule. While it preserves the backwards compatible configuration, with which it is possible to define an allow regex pattern for import aliases, this PR brings a way to configure any or both pattern types: allowRegex and/or denyRegex. This brings two types of configuration:

  1. The original one, allow pattern:
    # the original one, allow pattern
    [rule.import-alias-naming]
      arguments = ["^[a-z][a-z0-9]{0,}$"]
  2. The new one, both allow and deny patterns:
    [rule.import-alias-naming]
      arguments = [ { allowRegex = "^[a-z][a-z0-9]{0,}$", denyRegex = '^v\d+$' } ]

Closes #924.

chavacava commented 8 months ago

Thank you @denisvmedia