lightsoutAlpha

code-in-index-file

an index file holding code instead of only re-export lines

Deterministic checkadvisory by defaultbasecode

The argument

Index Files Hold No Code

An index.ts is a doorway, never a program. A package's entry is the list other packages build against, so an index file that declares values, wires tables, or runs anything makes that list illegible.

  1. Re-export lines only — export { Foo } from '<path>' and export type { Bar } from '<path>', plus comments
  2. Executable code gets a named entry file — conventionally main.ts — which imports what it runs from the files that declare it
  3. An entry point is a legitimate thing; it is just never named index.ts

The proof

fail
export const renderGreeting = (): string => 'hello';
pass
{
	"name": "code-in-index-file-pass-fixture",
	"private": true,
	"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": { "code-in-index-file": "advisory" }
"standards-checks": { "code-in-index-file": "off" }