golangci-lint: enable importas linter to force consistent aliases

This enforces the github.com/containerd/containerd/errdefs package to
be aliased as "cerrdefs". Any other alias (or no alias used) results
in a linting failure:

    integration/container/pause_test.go:9:2: import "github.com/containerd/containerd/errdefs" imported as "c8derrdefs" but must be "cerrdefs" according to config (importas)
        c8derrdefs "github.com/containerd/containerd/errdefs"
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-08 20:03:27 +02:00
parent 81e62af94a
commit f66374f6a8
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -5,6 +5,7 @@ linters:
- gosec
- gosimple
- govet
- importas
- ineffassign
- misspell
- revive
@ -24,6 +25,16 @@ linters:
- docs
linters-settings:
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
alias:
# Enforce alias to prevent it accidentally being used instead of our
# own errdefs package (or vice-versa).
- pkg: github.com/containerd/containerd/errdefs
alias: cerrdefs
govet:
check-shadowing: false
depguard: