folder-index-file
an `index.ts` in a folder that is not a package's entry
Deterministic checkadvisory by defaultbasecode
The argument
No Folder Index Files
An index.ts is a package's entry — the file its manifest publishes to other packages — and nothing else.
- Every import already names the declaring file, so an
index.tsin a folder lists names that nothing reads through it. It is a second copy of what the folder holds, kept by hand, that drifts the first time someone adds a file and forgets it. - A package's entry stays. Other packages import it, so it is the package's contract. It sits at the package root or its
src/, or the manifest names it — a subpath export such as"./contracts": "./src/contracts/index.ts"makes that file an entry too. - A route is not an index file. A file router's
src/routes/index.tsxis a route the framework loads.
Delete a folder's index.ts, and import each name from the file that declares it.
The proof
fail
export { ingestRecords } from './ingestRecords';
pass
{
"name": "folder-index-file-pass-fixture",
"private": true,
"exports": { ".": "./src/index.ts" },
"dependencies": {
"@tanstack/react-router": "1.168.3",
"@tanstack/react-start": "1.167.5"
}
}
Turn it down
Both lines go in your lightsout.config.json.
"standards-checks": { "folder-index-file": "advisory" }"standards-checks": { "folder-index-file": "off" }