admin-env-vars-import-meta - ESLint plugin rules
This rule requires admin code to use import.meta.env instead of process.env for environment variables, since admin code is bundled for the browser by Vite.
Severity#
warn. This rule is enabled in the recommended preset.
What it Targets#
This rule targets files in your project's src/admin directory. It reports access to process.env.
The following code is reported by the rule:
Instead, use import.meta.env:
Why it's Important#
Admin code runs in the browser via Vite, where is undefined. Using ensures your environment variables resolve correctly at runtime.
Learn more in the Environment Variables in Admin Development documentation.
Fixable#
This rule is auto-fixable. Run the linter with the --fix option to apply the fix automatically.
Turn it Off#
To turn off this rule, set it to off in your ESLint configuration:
Or disable it for a single line using an inline comment: