react-doctor/expo-no-non-inlined-env
Use static dotted access: process.env.EXPO_PUBLIC_NAME (computed/destructured reads aren't inlined and are undefined at runtime)
- Category: Bugs
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: react-native
- Enabled when: framework=react-native and capabilities=react-native
- Tags: react-native
- Default: Enabled
- Documentation: https://docs.expo.dev/guides/environment-variables/
Validate the diagnostic
Confirm the reported code matches this rule before you edit it.
Fires on two AST shapes in an Expo app file: (1) a computed MemberExpression whose object is the static process.env member (process.Identifier . env.Identifier, non-computed) — and it fires UNLESS the computed key is a string Literal that does NOT start with EXPO_PUBLIC_ (the source skips only that case via isNonExpoPublicLiteralKey at line 66), so a dynamic key process.env[key] AND an EXPO_PUBLIC_ string-literal key process.env["EXPO_PUBLIC_SECRET_TOKEN"] both fire, while a non-EXPO_PUBLIC_ string-literal key is skipped; (2) a VariableDeclarator whose id is an ObjectPattern and whose init is process.env, i.e. const { EXPO_PUBLIC_API_URL } = process.env. False positives to SUPPRESS: a literal computed key that does NOT start with EXPO_PUBLIC_, such as process.env["JEST_WORKER_ID"] or optional-chained process.env?.["EXPO_DEBUG"] — these are runtime/tooling probes expected to be absent in the bundle and the rule already skips them (verify the literal key text); static dotted access process.env.EXPO_PUBLIC_API_URL; whole-object aliasing const env = process.env (no ObjectPattern); computed access on an unrelated object like config.env[key]; and any Node/build-time file the engine should not have flagged anyway — *.config.[cm]?[jt]sx?, files under scripts//tools//tooling//cli//bin/, Expo Router +api/+html routes, *.server.* modules, and test files (*.test.*, *.spec.*, __tests__/, *.e2e.*).
How to fix
Follow the rule guidance while preserving unrelated behavior.
Copyable fix prompt
Copy this self-contained prompt into your coding agent after you confirm the diagnostic.
const { EXPO_PUBLIC_API_URL } = process.env with const EXPO_PUBLIC_API_URL = process.env.EXPO_PUBLIC_API_URL, and replace computed access process.env["EXPO_PUBLIC_API_URL"] or process.env[key] with process.env.EXPO_PUBLIC_API_URL. The key must be a literal property name written with dot notation and prefixed EXPO_PUBLIC_; dynamic keys cannot be inlined at all, so hardcode the specific var name rather than indexing by a variable. Move any genuinely server/Node-only var that must NOT ship to the client out of client code into a config, *.server.*, or +api route file instead. See https://docs.expo.dev/guides/environment-variables/Related rules
More Bugs rules from the rules reference:
react-doctor/form-control-requires-name: Form control is omitted from named submission datareact-doctor/hook-import-rename-loses-use-prefix: Hook import alias disables hook lint checksreact-doctor/hooks-no-nan-in-deps: Remove the literal NaN from the dependency array, or normalise it (Number.isNaN(x) ? 0 : x) before passing it in.react-doctor/html-label-has-single-control: Label wraps multiple native controlsreact-doctor/html-no-invalid-paragraph-child: Replace the wrapping <p> with a <div>, or hoist the block-level child out of the paragraph