[docs-infra] Restore build-only invariant throws via NEXT_RUNTIME guard by Janpot · Pull Request #48475 · mui/material-ui (original) (raw)

@Janpot

PR mui#48365 introduced the mui/no-guarded-throw lint rule and removed the if (process.env.NODE_ENV !== 'production') wrappers around several throws in docs components, making those invariants throw at client render time.

Restore the original "fail at build, not in the browser" semantics by guarding on process.env.NEXT_RUNTIME instead. The lint rule only matches NODE_ENV guards, and Next.js replaces NEXT_RUNTIME with undefined in client bundles, so the entire block is dead-code-eliminated from the browser.

Also drop the explicit 'mui/no-guarded-throw': 'error' override from eslint.config.mjs — the rule comes from the shared infra config.

@Janpot changed the title[docs] Restore build-only invariant throws via NEXT_RUNTIME guard [docs-infra] Restore build-only invariant throws via NEXT_RUNTIME guard

May 5, 2026

@Janpot Janpot added the scope: docs-infra

Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

label

May 5, 2026

@Janpot Janpot changed the title[docs-infra] Restore build-only invariant throws via NEXT_RUNTIME guard [docs-infra] Restore build-only invariant throws via NEXT_RUNTIME guard

May 5, 2026

@Janpot Janpot marked this pull request as ready for review

May 5, 2026 07:23

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})