Skip to content

Commit a71250d

Browse files
pieternclaude
andauthored
Add depguard rule to prevent imports of experimental/ packages (#4662)
## Summary - Adds a `depguard` lint rule that prevents non-experimental code from importing `experimental/` packages - Only `cmd/cmd.go` and `cmd/experimental/` are allowed as entry points into experimental code - The existing violation in `cmd/apps/init.go` is excluded with a TODO to address later ## Test plan - [x] `golangci-lint run ./...` passes with 0 issues - [x] Verified that new imports of `experimental/` from outside the allowed files are flagged 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 911df0f commit a71250d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.golangci.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ linters:
1919
- exhaustive
2020
- copyloopvar
2121
- forbidigo
22+
- depguard
2223
settings:
24+
depguard:
25+
rules:
26+
no-experimental-imports:
27+
# depguard matches against absolute file paths, so patterns must
28+
# start with **/ to match regardless of the repository location.
29+
files:
30+
- "**"
31+
- "!**/cmd/cmd.go"
32+
- "!**/cmd/experimental/**"
33+
- "!**/experimental/**"
34+
deny:
35+
- pkg: "github.com/databricks/cli/experimental"
36+
desc: "must not import experimental/ packages; use an interface or move the dependency"
2337
forbidigo:
2438
forbid:
2539
- pattern: 'term\.IsTerminal'
@@ -107,6 +121,10 @@ linters:
107121
- path: bundle/direct/dresources/.*_test.go
108122
linters:
109123
- exhaustruct
124+
# TODO: remove these exceptions by moving the dependency out of experimental/.
125+
- path: cmd/apps/init.go
126+
linters:
127+
- depguard
110128
issues:
111129
max-issues-per-linter: 1000
112130
max-same-issues: 1000

0 commit comments

Comments
 (0)