file-placement
Where a file belongs, from who uses it.
Deterministic checkAgent checkAdvises by default
The rule
Agents read this text as written when they write and review code.
Put a file where its users are.
- Used by one file: beside that file, in its module folder.
- Used by two or more files: in the
common/of the lowest folder that holds them all. - Used from outside its subject folder: at the top level of that subject folder.
When a file gains a user, move it, update the imports, and check the move made no circular imports.
Then where a file sits shows who uses it.
Examples
The check flags the incorrect code and passes the correct code; the agent judges what the check cannot see. 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
srcbillingcommoninvoices
// Incorrect: sendInvoice.ts uses this too, so it sits too low. It belongs in// src/common/, the lowest folder that holds both users.export const formatMoney = ({ cents }: { cents: number }): string => `$${(cents / 100).toFixed(2)}`;
Correct
srcbillingchargeCustomercommoncommoninvoices
// Correct: billing and invoices both use this, and src/ is the lowest folder// that holds both.export const formatMoney = ({ cents }: { cents: number }): string => `$${(cents / 100).toFixed(2)}`;
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"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.
{"standards-rule-settings": {"file-placement": "advisory"}}