From 9f68bc0a2b61cb07be970593daab5508f8e8f212 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 16 May 2025 12:27:29 +0200 Subject: [PATCH] golangci-lint: enable importas linter Signed-off-by: Sebastiaan van Stijn --- .golangci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 837218dc74..958b86998f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,6 +40,7 @@ linters: - gosec # Detects security problems. - govet - ineffassign + - importas # Enforces consistent import aliases. - misspell # Detects commonly misspelled English words in comments. - nakedret # Detects uses of naked returns. - nilerr # Detects code that returns nil even if it checks that the error is not nil. @@ -108,6 +109,21 @@ linters: lll: line-length: 200 + 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/errdefs + alias: cerrdefs + - pkg: github.com/opencontainers/image-spec/specs-go/v1 + alias: ocispec + # Enforce that gotest.tools/v3/assert/cmp is always aliased as "is" + - pkg: gotest.tools/v3/assert/cmp + alias: is + nakedret: # Disallow naked returns if func has more lines of code than this setting. # Default: 30