Skip to content

Lint: packages import only each other's public entry points - #38

Merged
kaiserarg merged 1 commit into
mainfrom
agent/5-boundary-lint
Nov 28, 2026
Merged

kaiserarg merged 1 commit into
mainfrom
agent/5-boundary-lint

Conversation

@kaiserarg

Copy link
Copy Markdown
Contributor

Ticket #5

Adds the ESLint rule inspa/package-boundaries (scripts/eslint-boundaries.mjs), turned on for every file in eslint.config.js.

What fails

  • A bare import into a package's source: @inspa/<pkg>/src/... (any @inspa/*, existing or not) and <workspace name>/src/... (inspa/src/...). Public subpaths such as @inspa/core/guardrails stay legal.
  • A relative import that leaves the file's package folder for another one. Package folders are the workspace folders from the root package.json (packages/*, apps/*, examples/*). Everything else (e2e/, scripts/, root configs) counts as the root, so ../packages/cli/src/... from e2e/ fails too.
  • Every form a module path takes: import/export ... from, import(), require(), TS import("...") types and import x = require(), and vi.mock/doMock/unmock/importActual/importMock.

Existing violations: there are 16. Each is allow-listed as one exact { file, import } pair in BOUNDARY_ALLOW in eslint.config.js, with a comment on why it is there. A new crossing import fails, even in a file that is already on the list. None of the 16 are in platform paths (6 e2e specs, examples/invoices/vitest.config.ts, 9 engine tests), so the list is on the ticket for their owners. A test fails on any entry whose import is gone, so the list can only shrink.

How to verify

npm ci && npm run build
npm run lint                                         # green
npx vitest run scripts/eslint-boundaries.test.mjs    # 9 tests: rule cases + stale allow-list check
echo "import '@inspa/core/src/naming.js'; import '../../core/src/naming.js';" > packages/ui/src/zz.ts && npm run lint; rm packages/ui/src/zz.ts   # 2 errors

I also ran npm run typecheck:built (green) and npx vitest run --project packages scripts/ (10 files, 204 tests, green).

Closes #5

Agent: platform-20261128T0857-eng-1


Generated by Claude Code

New ESLint rule inspa/package-boundaries (scripts/eslint-boundaries.mjs) fails
bare imports into a package's source (@inspa/<pkg>/src/..., inspa/src/...) and
relative imports that leave the file's workspace folder for another one. It
checks import/export-from, import(), require(), TS import types and
import-equals, and vi.mock()-family calls.

The 16 existing crossings are allow-listed one exact import at a time in
eslint.config.js with a comment each; a test fails on any entry whose import
is gone, so the list only shrinks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8joVCWcEGQMNZz9JkMJmw
@kaiserarg

Copy link
Copy Markdown
Contributor Author

QA approved by platform-20261128T0857-qa-38.

QA (platform-20261128T0857-qa-38) on bb20691. Ran: npm ci, npm run build (green), npm run lint (green, whole repo), npm run typecheck:built (green), npx vitest related --run on the 3 changed files (9/9 pass).
Negative probes: real eslint on new files, 7/7 crossings reported (deep @inspa/core/src, deep inspa/src, relative ui->core, export * from vite-plugin src, typeof import() type, two e2e root->package). Via stdin it also catches .tsx, .mjs, .cjs require, and apps/desktop->packages. A new crossing import added to the allow-listed e2e/proxy-hmr.spec.ts still fails, so allow-listing is per import, not per file. Changing the allow-listed import in token-themes-parity.test.ts made the stale-entry test fail, naming the entry (file restored after).
Both acceptance criteria are met: the rule fails on @inspa//src and on cross-folder relative imports, and the 16 existing violations are allow-listed with comments and listed on #5. Every path is in platform paths. It matches the master doc's 'no package imports another package's internals'.
No e2e run: lint-only change, no feature touched. The architect agent couldn't be spawned (no subagent tool here), so I did its checklist myself; notes are on #5.


Generated by Claude Code

@kaiserarg
kaiserarg merged commit ac61379 into main Nov 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Boundary lint: packages import only each other's public entry points

2 participants