lightsoutAlpha

cross-package-sharing

Flags code two packages need duplicated per package instead of moved to the shared one.

Agent checkAdvises by default

Why this rule

Cross-Package Sharing (packages/shared/)

Code needed by 2+ packages belongs in a shared package — not duplicated per-package.

A pure-contracts/shared package — one where everything is public by design — is a common/-like space: its src/ holds domain folders, not modules. The companion test decides this per folder: a folder whose every file is something its users call directly is a domain folder.

Examples

The agent flags code like the incorrect example and accepts code like the correct one. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.

Incorrect

packagesapisrcpermissionsutilsfrontendsrcpermissionsutils
packages/api/src/permissions/utils/hasPermission.ts
export const hasPermission = () => true;

Correct

packagesapisrcauthsharedsrcpermissionsutils
packages/api/src/auth/getAuth.ts
import { hasPermission } from '@scope/shared/permissions/utils/hasPermission';
export const getAuth = hasPermission;

Configure

  • Block"blocking"Stops a run when a file the run changed breaks the rule.
  • Advise"advisory"Reports it and hands it to the refactor agent. Never stops a run.
    Default
  • Off"off"Not checked. Use it when your own linter already enforces the rule.

Add this to your lightsout.config.json, then change the value.

lightsout.config.json
{
"standards-checks": {
"cross-package-sharing": "advisory"
}
}