Skip to content

Next.js

The nextjs configuration type-checks the app after Next.js writes its route types, and adds the Next.js lint rules, a rule for server modules, and two rules for next.config. It needs typescript, react, and react-dom, so the React rules also run.

Check Stage Level What it does
nextjs/tsc push basic Has Next.js write its types, then type-checks the app with the strict compiler options.

A new clone has no next-env.d.ts and no route types, so tsc alone fails on the imports that Next.js resolves. Before each push, nextjs/tsc runs next typegen, then type-checks the app, and it does not change your files. typescript/tsc does not run in a Next.js scope.

The check runs the next package of your project, which must be version 15.5.0 or later. When next typegen fails, the check stops and prints the cause. CI needs no extra step, because the gspot workflow runs next typegen too.

javascript/eslint adds the core-web-vitals preset of @next/eslint-plugin-next, the next preset of eslint-plugin-react-refresh, and @next/next/no-async-client-component. @next/next/no-html-link-for-pages runs only when the project has a pages or src/pages folder. Level all adds rules for Google Analytics scripts, <img> elements, and custom fonts in a single page.

gspot/require-server-only makes a file under a server folder, or named *.server.*, import server-only or declare "use server", so that a client bundle never includes it.

In next.config.* files, the gspot/restricted-syntax rule reports two patterns at both levels:

Pattern Message
ignoreBuildErrors: true or ignoreDuringBuilds: true This option lets next build pass with errors. Remove it.
A key under env whose name holds SECRET, TOKEN, PASSWORD, PRIVATE_KEY, or API_KEY A key under env is written into the client bundle. Read this secret on the server.

gspot accepts the file names, folder layouts, default exports, and export names of the Next.js route, metadata, middleware, and proxy files, such as page.tsx, not-found.tsx, and generateMetadata. It treats next-env.d.ts as a generated file, and most checks skip it.

At level all, three shapes of a Next.js app still get a finding. export const dynamicParams reports unicorn/consistent-boolean-name, and the default export of a Cloudflare Worker entry, or of the module that images.loaderFile names, reports import-x/no-default-export. Ignore the rule for that file with a reason.