lightsoutAlpha

filename-mismatch

How a file's name follows what it exports.

Deterministic checkAdvises by default

The rule

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

Name a file exactly as its export, casing included: buildVersionedLabel.ts, UserProfile.ts. A file with a union and its member types takes the union's name.

A file named like its export is found by searching for the export.

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

srcbilling
src/billing/chargeLabel.ts
export const getChargeLabel = ({ amount }: { amount: number }): string => `${amount}`;

Correct

srcbillingconfigsync
package.json
{
"name": "filename-mismatch-pass-fixture",
"private": true
}

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": {
"filename-mismatch": "advisory"
}
}

Packs that select it