Skip to content

enforce-file-structure

Require imports before body statements and require use server to be the first statement.

Why

Interleaved imports obscure module dependencies, while a displaced use server string is not an active directive.

Fix

Move use server to the first statement when present, then place imports before declarations and executable statements.

Examples

Before — flagged An import follows a module declaration
src/component.ts
export const x = 1;
import { z } from "zod";
After — preferred Imports precede module declarations
src/component.ts
import { z } from "zod";
export const schema = z.string();