feature-layout
Which folders the framework adds to a feature, and what a route reaches into.
The rule
Agents read this text as written when they write and review code.
Lay a feature out as the React layout rules say, with two folders the framework adds: queries/ for its query options factories and server/ for its server functions. A query or server function several features use sits in queries/ or server/ at the top of src/, as the shared layer rule says of everything shared.
A route reaches a feature through screens/, queries/, utils/, constants/, types/ and server/, never through components/ or hooks/.
Then what a route may touch, and where the server begins, are both read from the tree.
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
import { createFileRoute } from '@tanstack/react-router';import { IssuesScreen } from '../features/issues/components/IssuesScreen.tsx';import { issuesQueryOptions } from '../features/issues/queries/issuesQueryOptions.ts';// Incorrect: the route imports from the feature's components/, which is the// screen's to compose from, not the route's to reach.export const Route = createFileRoute('/issues')({loader: ({ context }) => context.queryClient.ensureQueryData(issuesQueryOptions()),component: IssuesScreen,});
Correct
import { createFileRoute } from '@tanstack/react-router';import { issuesQueryOptions } from '../features/issues/queries/issuesQueryOptions.ts';import { IssuesScreen } from '../features/issues/screens/IssuesScreen.tsx';// Correct: the route reaches the feature through screens/ and queries/ only.export const Route = createFileRoute('/issues')({loader: ({ context }) => context.queryClient.ensureQueryData(issuesQueryOptions()),component: IssuesScreen,});
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": {"feature-layout": "advisory"}}