Skip to content

Commit 4bead2b

Browse files
committed
Tooling: check for circular deps in TS code
1 parent d200d8c commit 4bead2b

6 files changed

Lines changed: 252 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Run the smallest set of checks possible for efficiency while maintaining confide
4949
- Running a Svelte test: `cd apps/desktop && pnpm vitest run -t "<test_name>"`
5050
- Running all Rust/Svelte tests: `./scripts/check.sh --rust` or `--svelte`
5151
- Running specific checks `/scripts/check.sh --check {desktop-svelte-prettier|desktop-svelte-eslint|stylelint|css-unused
52-
|svelte-check|knip|type-drift|svelte-tests|desktop-smoke|e2e-linux-typecheck|desktop-e2e-linux (slow)|rustfmt|clippy
52+
|svelte-check|import-cycles|knip|type-drift|svelte-tests|desktop-smoke|e2e-linux-typecheck|desktop-e2e-linux (slow)|rustfmt|clippy
5353
|cargo-audit|cargo-deny|cargo-udeps|jscpd-rust|cfg-gate|rust-tests|rust-tests-linux (slow)|license-server-prettier
5454
|license-server-eslint|license-server-typecheck|license-server-tests|gofmt|go-vet|staticcheck|ineffassign|misspell
5555
|gocyclo|nilaway|deadcode|go-tests|website-prettier|website-eslint|website-typecheck|website-build

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"globals": "^16.5.0",
7373
"jsdom": "^27.4.0",
7474
"knip": "^5.85.0",
75+
"oxlint": "^1.52.0",
7576
"postcss-html": "^1.8.1",
7677
"prettier": "^3.8.1",
7778
"prettier-plugin-svelte": "^3.5.1",

pnpm-lock.yaml

Lines changed: 214 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/check/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ tests, type checkers before tests.
157157
| App | Tech | Checks |
158158
|-----|------|--------|
159159
| Desktop | Rust | rustfmt, clippy, cargo-audit, cargo-deny, cargo-udeps, jscpd, tests, tests-linux (slow) |
160-
| Desktop | Svelte | prettier, eslint, stylelint, css-unused, svelte-check, knip, type-drift, tests, smoke, e2e-linux-typecheck, e2e-linux (slow) |
160+
| Desktop | Svelte | prettier, eslint, stylelint, css-unused, svelte-check, import-cycles, knip, type-drift, tests, smoke, e2e-linux-typecheck, e2e-linux (slow) |
161161
| Website | Astro | prettier, eslint, typecheck, build, html-validate, e2e |
162162
| Website | Docker | docker-build |
163163
| License server | TS | prettier, eslint, typecheck, tests |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package checks
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
"path/filepath"
7+
)
8+
9+
// RunImportCycles uses oxlint's import plugin to detect circular imports in TypeScript/Svelte code.
10+
func RunImportCycles(ctx *CheckContext) (CheckResult, error) {
11+
desktopDir := filepath.Join(ctx.RootDir, "apps", "desktop")
12+
13+
cmd := exec.Command("pnpm", "exec", "oxlint",
14+
"--import-plugin",
15+
"--allow", "all",
16+
"--deny", "import/no-cycle",
17+
"src",
18+
)
19+
cmd.Dir = desktopDir
20+
output, err := RunCommand(cmd, true)
21+
if err != nil {
22+
return CheckResult{}, fmt.Errorf("circular imports detected\n%s", indentOutput(output))
23+
}
24+
25+
return Success("No circular imports"), nil
26+
}

scripts/check/checks/registry.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ var AllChecks = []CheckDefinition{
133133
DependsOn: []string{"desktop-svelte-eslint"},
134134
Run: RunSvelteCheck,
135135
},
136+
{
137+
ID: "desktop-svelte-import-cycles",
138+
Nickname: "import-cycles",
139+
DisplayName: "import cycles (oxlint)",
140+
App: AppDesktop,
141+
Tech: "🎨 Svelte",
142+
DependsOn: nil,
143+
Run: RunImportCycles,
144+
},
136145
{
137146
ID: "desktop-svelte-knip",
138147
Nickname: "knip",

0 commit comments

Comments
 (0)