Skip to content

Check import cycles with knip, and turn on ruff's preview F401 and prefer-const - #5222

Merged
max-sixty merged 3 commits into
mainfrom
dead-code-check
Nov 3, 2026
Merged

max-sixty merged 3 commits into
mainfrom
dead-code-check

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A survey of candidate lints, each run over the tree with a sample of its findings read, found three that report only real problems here. This adds them and fixes what they reported.

  • knip's cycles, which reads the whole tree and the framework facade's edges. It found two import cycles dependency-cruiser's no-cycle couldn't see. voice.js reached the application publisher through /runtime/framework.js, which the cruiser excludes, to import Lit's html; it now imports html from /vendor/lit.js, as icons.js does. build/runtime-bundle.mjs and build/browser/build.mjs imported each other for signalsPath, which now lives in runtime-bundle.mjs, the module that compiles the signals in. no-cycle is deleted: on a planted static cycle knip fails as it did, and the dynamic-import cycles only the cruiser reported have no evaluation order to break.
  • ruff's preview behaviour for the selected rules (preview with explicit-preview-rules, so no preview rules), whose F401 reports an unused import http.cookiejar beside a used import http.client. It removed five such imports from tests, one of them from a test that landed on main since the survey.
  • eslint's prefer-const with ignoreReadBeforeAssign, which leaves the forward declarations boot reads from closures (17 of the default form's 21 findings) and reports the four bindings that were never reassigned.

The survey also found three page styles reading tokens the theme doesn't define, so the declaration computed to nothing; they now name the ones it does: data-explorer.html's --r-sm (--r-s), the notification playground's --bad (--danger), and the cutover eval fixture's --border (--border-2). referencing, which src/leaf imports directly, is now a declared dependency rather than one jsonschema brings.

Rejected after measuring: further ruff families, about 45 eslint core rules, typescript-eslint's type-aware rules (211 s and a second TypeScript), oxlint's no-floating-promises (22 calls missing the tree's void marker, none failing silently), ty's default-off rules, stylelint, commented-out-code detectors and jscpd, each either noise or clean.

Validation: every pre-commit hook and pnpm run check:browser pass on the merged tree, and the 737 runtime tests passed on the change before main was merged in.

This was written by Claude Code on behalf of max-sixty

…efer-const

A survey of candidate lints, each run over the tree with a sample of its findings
read, found three that report only real problems here:

- knip's `cycles`, which reads the whole tree and the framework facade's edges.
  It found two cycles dependency-cruiser's `no-cycle` couldn't see: voice.js
  reached the application publisher through `/runtime/framework.js`, which the
  cruiser excludes, to import Lit's `html`, and build/runtime-bundle.mjs and
  build/browser/build.mjs imported each other for `signalsPath`. voice.js now
  imports `html` from `/vendor/lit.js`, and `signalsPath` lives in
  runtime-bundle.mjs, which compiles the signals in. `no-cycle` is deleted:
  knip reports every static cycle it did, and the dynamic-import cycles it also
  reported have no evaluation order to break.
- ruff's preview behaviour for the selected rules (no preview rules), whose F401
  reports an unused `import http.cookiejar` beside a used `import http.client`.
  It removed four such imports from tests.
- eslint's `prefer-const` with `ignoreReadBeforeAssign`, which leaves the forward
  declarations boot reads from closures and reports the four bindings that were
  never reassigned.

The survey also found three page styles reading tokens the theme doesn't define,
now pointed at the ones it does: data-explorer's `--r-sm` (`--r-s`), the
notification playground's `--bad` (`--danger`), and the cutover fixture's
`--border` (`--border-2`). `referencing`, which src/leaf imports directly, is now
a declared dependency rather than one jsonschema happens to bring.
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-errors.js
@max-sixty
max-sixty merged commit 3e1cbbc into main Nov 3, 2026
4 checks passed
@max-sixty
max-sixty deleted the dead-code-check branch November 3, 2026 18:12
max-sixty pushed a commit that referenced this pull request Nov 18, 2026
…t cycles (#5301)

Some agent instructions still point to where things used to live. #5121
moved every `:root` theme token from `browser/base.css` into
`browser/styles/tokens.css`, and #5222 moved the import-cycle check from
dependency-cruiser to knip. This PR updates those pointers and changes
no rule.

- **`browser/AGENTS.md`**
- `--lf-line` and `--raise-1` to `--raise-3` now point to
`styles/tokens.css`.
- The Layout/style/widget rule now says the style's tokens are in
`styles/tokens.css`.
- The module-boundaries paragraph now credits knip (`knip.config.js`)
with rejecting import cycles. `.dependency-cruiser.mjs` has had no cycle
rule since #5222.
- **The developing-leaf glossary:** **Focus ring** now places
`--focus-ring` in `styles/tokens.css`.
- **The shipped `skills/leaf/references/package-themes.md`:** the
default palette and the "Where it stands" tokens (`--focus-region-gap`,
etc.) now point to `browser/styles/tokens.css`. An agent writing a theme
would otherwise search `base.css` and find none of them.

I grepped both files to confirm each named token is declared in
`tokens.css` and not in `base.css`. `prek run` passes on the changed
files.

#5299 fixes the same stale pointers in code comments. This PR is
separate because these paths need the control-plane owner's approval.

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants