mgechev / revive

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

Make import-blacklist configurable for test files #860

Closed denisvmedia closed 1 year ago

denisvmedia commented 1 year ago

Is your feature request related to a problem? Please describe. I'd like to enforce some import restrictions for our test files, but this is not possible due to the following:

https://github.com/mgechev/revive/blob/df39256ea77c2cfa014172d0c421bf300a112384/rule/imports-blacklist.go#L55

Describe the solution you'd like I'd like to either remove the if condition (which is probably undesirable because it might bring issues for the existing projects) or make it configurable (preserving the current behavior as default).

Describe alternatives you've considered I could have just done that by catching regex values in my code, but that's not precise and I'd like to avoid it.

Additional context I can provide a PR, if it's something that the project can accept.

chavacava commented 1 year ago

Hi @denisvmedia , thanks for opening the issue. I personally do not like these hardcoded special treatment for test files and removing the if seems to me the right thing to do. Excluding test files could be done by other means (like #850)