lightsoutAlpha

shared-package-criteria

What belongs in the shared package.

Agent checkAdvises by default

The rule

Agents read this text as written when they write and review code.

In a repo with several packages, never copy code from one package into another. Put it in the shared package, but only when two or more packages need it and it is a contract both sides agree on, such as constants, error codes or pure functions.

  • One package needs it: put it in that package's common/.
  • It depends on a library only one package uses: keep the pure part shared, and wrap it in that package.

Copies in each package drift apart, and a fix then reaches only one of them.

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

packagesfrontendsrcbillingsharedsrcbillingutils
packages/frontend/src/billing/renderInvoiceRow.ts
import { getInvoiceRowClass } from '@scope/shared/billing/utils/getInvoiceRowClass';
export const renderInvoiceRow = getInvoiceRowClass;

Correct

packagesfrontendsrcbillingsharedsrcpermissionsutils
packages/frontend/src/billing/getInvoiceRowClass.ts
export const getInvoiceRowClass = () => 'row';

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-rule-settings": {
"shared-package-criteria": "advisory"
}
}

Packs that select it