Skip to content
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

Using importas within golangci-lint w/ both no-unaliased and no-extra-aliases fails #15

Open
johndlong opened this issue Jul 17, 2023 · 1 comment · May be fixed by #20
Open

Using importas within golangci-lint w/ both no-unaliased and no-extra-aliases fails #15

johndlong opened this issue Jul 17, 2023 · 1 comment · May be fixed by #20

Comments

@johndlong
Copy link

Looking to leverage both no-unaliased and no-extra-aliased flags in golangci-lint, and end up getting results where un-aliased imports start giving problematic results. Ideally we'd have the restrictions provided by both the flags (consistent, always-defined aliases; rejecting any new aliases that aren't described)

linters-settings:
  importas:
    no-unaliased: true
    no-extra-aliases: true
    alias:
...

Which results in a number of issues, where even standard libraries act as if they have an alias but not in the config:

import "time" has alias "" which is not part of config (importas)
        "time"
@nightlyone
Copy link

To add a bit more detail what the behavior should be in that case:

  • only the packages listed with an alias should always have the alias and never be imported without aliases.

That makes it easier to copy code snippets around between files with those aliases.

@F0rzend F0rzend linked a pull request Oct 12, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants