@noctcore/eslint-plugin-rsc
React Server Components and App Router correctness: the control-flow errors a server component must not swallow.
What it solves
Section titled “What it solves”Server-side React code has control flow that does not look like control flow. In the Next.js App Router, redirect(), notFound(), forbidden() and unauthorized() work by throwing an error the framework catches further up. Put one inside a try whose catch handles every error and the navigation silently never happens: the page renders its fallback, the Server Action returns { error }, and nothing in the types or the tests says why.
What it will yell at you about
Section titled “What it will yell at you about”It will yell at you about a navigation call inside a try that swallows it. The rule resolves the call to its next/navigation import, aliases and namespace imports included, so a function of the same name from anywhere else is left alone, and it accepts a catch that calls unstable_rethrow(error) or rethrows the caught error. It needs no configuration and ships at error in recommended. The package aims to stay framework-neutral where the RSC model allows; rules tied to one framework’s API, like this one, say so and only fire on that framework’s imports. It is a bad fit only in the sense that it does nothing outside a React Server Components codebase.
Install and configure
Section titled “Install and configure”npm install --save-dev @noctcore/eslint-plugin-rsc @typescript-eslint/parser# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-rsc @typescript-eslint/parser// eslint.config.jsimport tsParser from '@typescript-eslint/parser';import rsc from '@noctcore/eslint-plugin-rsc';
export default [ { ...rsc.configs.recommended, files: ['**/*.{ts,tsx}'], languageOptions: { parser: tsParser }, },];The recommended preset enables 1 of 1 rule.
Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first
read is no-navigation-throw-in-try.
| Rule | What it reports | Preset | Fix | Types |
|---|---|---|---|---|
no-navigation-throw-in-try | Disallow redirect(), notFound() and the other throwing next/navigation calls inside a try whose catch swallows the error instead of rethrowing it. | error |
Preset: severity in configs.recommended; off means the preset registers the rule switched off, not listed means it leaves the rule out; both are opt-in, so you turn the rule on yourself. Fix: whether the rule ships an autofix or an editor suggestion. Types: whether the rule needs a type-checked program (parserOptions.projectService).