lightsoutAlpha

dead-export

Code that nothing uses any more.

Deterministic checkBlocks by default

The rule

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

Delete an export that nothing references, not even a test, as soon as it becomes unused. This covers interfaces, types and functions as well as values.

  • Never keep code in case it is needed later: version history still has it.
  • When you are not sure whether something is used, search before you delete it.

Unused code still has to be read, and kept compiling, by everyone who passes it.

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

srcfeature
src/feature/buildGreeting.ts
// Nothing in this repo mentions `buildGreeting` — no module, no entry, no
// test. Version control has its history; the file does not need to keep it.
export const buildGreeting = ({ name }: { name: string }): string => `Hello, ${name}.`;

Correct

srcfeature
src/index.ts
// `renderGreeting` is published by the package entry and `buildGreeting` used
// by it — every export in the package has something that consumes it.
export { renderGreeting } from './feature/renderGreeting';

Configure

  • Block"blocking"Stops a run when a file the run changed breaks the rule.
    Default
  • Advise"advisory"Reports it and hands it to the refactor agent. Never stops a run.
  • 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": {
"dead-export": "blocking"
}
}

Packs that select it