TypeScript · correctness
no-raw-env
eslint:no-raw-env Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
Raw environment reads are untyped and defer invalid configuration failures until use.
Fix
Validate environment values at startup and import the typed configuration object.
Before / after
Executed by this rule’s unit tests.
Before
Do not read raw configuration
const url = process.env.DATABASE_URL; After
Read validated configuration
import { env } from './env.js'; const url = env.DATABASE_URL; Limits
- Host markers, assignment targets, tests, scripts, build config, and validated boundaries are excluded.
Message IDs
noRawEnv