Skip to content

no-wildcard-imports

Reports an import of every name of a package or module (import a.b.*; in Java and Kotlin, from a import * in Python, import . "fmt" in Go). A named import is not reported. Off by default.

A wildcard hides where a name comes from, and a name added to the package later can silently clash with one in the file or change which one a call reaches. Tools and readers cannot tell from the imports what the file uses.

To fix, import the names the file uses.

Reported
package a
import (
. "fmt"
"os"
_ "embed"
m "math"
)
import . "strings"
csharp:
lint:
rules:
no-wildcard-imports:
level: warn # off (default), warn, error
options:
wildcard_aliases: ["."]
go:
lint:
rules:
no-wildcard-imports:
level: warn # off (default), warn, error
options:
wildcard_aliases: ["."]
java:
lint:
rules:
no-wildcard-imports:
level: warn # off (default), warn, error
options:
wildcard_aliases: ["."]
js:
lint:
rules:
no-wildcard-imports:
level: warn # off (default), warn, error
options:
wildcard_aliases: ["."]
kotlin:
lint:
rules:
no-wildcard-imports:
level: warn # off (default), warn, error
options:
wildcard_aliases: ["."]
python:
lint:
rules:
no-wildcard-imports:
level: warn # off (default), warn, error
options:
wildcard_aliases: ["."]
Option Type Default Description
wildcard_aliases list ["."] The aliases that bring in every name of the imported package

Enabled by the presets: go/revive, java/google, kotlin/ktlint.

Suppress one line with sudsy-disable-next-line no-wildcard-imports in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
checkstyle AvoidStarImport partial No allow-list option.
ktlint no-wildcard-imports full
revive dot-imports full
ruff F403 full