codemod(v6): Convert all process.env usage to dot notation #8611
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Process Env Dot Notation
Finds all cases where
process.env
is accessed via array notation (specifically string literals), and converts it to dot notation.NOTE - this does not deal with dynamic access case. This is something users will need to do themselves
Linting rule for this: #8612
Webpack support array notation for both dev and prod
Only basic strings work in production. You can't have expressions
In Webpack, if you try to access
process.env
you'll get "MISSING_ENV_VAR" back. But if you try to access an env var that doesn't exist you getundefined
(same behavior in both dev and prod)Sometimes you might want to use array notation for tests, like we do in the framework here (it's got red squiggles because I've got our new eslint rule for this set to report it as an error)