lightsoutAlpha

index-files

Which folders have an index file, and where an import points.

Deterministic checkAdvises by default

The rule

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

Only a package's entry is an index file, and nothing inside the package imports through it. Every import names the file that declares what it imports: @/ingestion/ingestRecords, never @/ingestion.

  • Delete an index file in any other folder, and import each name from the file that declares it.
  • Import from another package through its entry, such as @acme/engine, never by a path into its src/.
  • An index file may re-export from another index file, and its own test imports it.

An import through an index file loads every file it re-exports to reach one name, and a test runner, unlike a bundler, pays for all of them.

Examples

The check flags the incorrect code and passes the correct code. 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

srcingestioncommonutilsreporting
src/reporting/buildReport.ts
import { ingestRecords } from '../ingestion';
export const buildReport = (): number => ingestRecords();

Correct

srcingestioncommonutilsreporting
src/reporting/buildReport.ts
import { ingestRecords } from '../ingestion/ingestRecords';
export const buildReport = (): number => ingestRecords();

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": {
"index-files": "advisory"
}
}

Packs that select it