-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importas: detect duplicate alias or package in the configuration #3753
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should unique aliases be an opt in? F.ex. by default the linter supports unaliased imports even if it's added with alias
so supporting multiple aliases feels similar (unaliased + alias1 vs. alias1 + alias2)?
Also I think since the linter uses a map this should already report a diagnostic since first adding alias1
and then alias2
will have alias2
override alias1
making imports with alias1
not allowed.
Currently this change makes the linter behave differently depending on if it's run natively or through golangci-lint
which I think is nice to avoid. But maybe I'm missing some context here?
It's a not different behavior, it's just a better way to detect problems inside the configuration. The provider configuration uses a map just because this is "easier" with CLI flag parsing.
As the key of the map is the package, the linter is not able to handle multiple aliases because it will not see them. The fact to use the same alias for multiple packages is the opposite of the target of this linter: use the same import aliases everywhere for one package. The |
My bad, I thought error severity would affect running or exit code but if it's just logging it makes sense. Regarding the map, my thought was to change this behaviour if you wanted to support different behaviour and/or have this logic in the linter instead. |
Produce an error log when a package has multiple aliases:
Produce an error log when an alias is used for several packages: