Best Practices warn by default astro-doctor/no-process-env

no-process-env

Disallow process.env in Astro files — use import.meta.env instead.

Why

process.env is a Node.js-specific API that does not work in client-side contexts. import.meta.env is Astro's standard for environment variables: it works in both server and client code, respects the PUBLIC_ prefix for client-safe exposure, and is type-safe with the Astro env schema.

Examples

Incorrect

Using process.env

---
const apiKey = process.env.API_KEY
const publicUrl = process.env.PUBLIC_SITE_URL
---
<p>{publicUrl}</p>

Correct

Using import.meta.env

---
const apiKey = import.meta.env.API_KEY
const publicUrl = import.meta.env.PUBLIC_SITE_URL
---
<p>{publicUrl}</p>

Configuration

Override the default severity in your ESLint config:

// eslint.config.js
import astroDoctorPlugin from '@santi020k/eslint-plugin-astro-doctor'

export default [
  astroDoctorPlugin.configs.recommended,
  {
    rules: {
      'astro-doctor/no-process-env': 'error',   // or 'warn' or 'off'
    },
  },
]
       
  

Or in your doctor.config.ts:

export default {
  rules: {
    'astro-doctor/no-process-env': 'error',
  },
}
       
  

All rules