noUndeclaredEnvVars
Ta treść nie jest jeszcze dostępna w Twoim języku.
Summary
Section titled “Summary”- Rule available since:
v2.3.10 - Diagnostic Category:
lint/nursery/noUndeclaredEnvVars - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Same as
turbo/no-undeclared-env-vars
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noUndeclaredEnvVars": "error" } } }}Description
Section titled “Description”Disallow the use of undeclared environment variables.
In Turborepo projects, environment variables used in tasks must be declared
in the turbo.json(c) configuration file to ensure proper caching behavior.
Using undeclared environment variables can lead to incorrect cache hits
and unpredictable build behavior.
This rule checks for process.env.VAR_NAME and import.meta.env.VAR_NAME
accesses and validates them against:
- Environment variables declared in
turbo.json(c)(globalEnv,globalPassThroughEnv, task-levelenv, and task-levelpassThroughEnv) - Environment variables specified in the rule’s
allowedEnvVarsoption - Default allowed variables (common system vars and framework-specific patterns)
Default Allowed Variables
Section titled “Default Allowed Variables”The following environment variables are always allowed without explicit declaration:
System variables:
CI,HOME,PATH,PWD,SHELL,TZ,USER
Node.js:
NODE_ENV
Framework and provider-specific patterns (all variables matching these prefixes):
NEXT_PUBLIC_*(Next.js)VITE_*(Vite)REACT_APP_*(Create React App)VUE_APP_*(Vue CLI)NUXT_*(Nuxt)GATSBY_*(Gatsby)EXPO_PUBLIC_*(Expo)VERCEL,VERCEL_*(Vercel)
Examples
Section titled “Examples”Invalid
Section titled “Invalid”When MY_VAR is not declared in turbo.json or the allowed list:
const value = process.env.MY_VAR;// NODE_ENV is always allowedconst value = process.env.NODE_ENV;Options
Section titled “Options”Use the options to specify additional environment variables that are not declared in globalEnv,
globalPassThroughEnv, or task-level env/passThroughEnv in turbo.json.
Supports regular expression patterns (anchors ^ and $ are implicit).
{ "linter": { "rules": { "nursery": { "noUndeclaredEnvVars": { "options": { "allowedEnvVars": [ "MY_APP_.*", "ACME_TOKEN" ] } } } } }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.