Plugin to disallow destructuring from process.env
. process.env.*
could be statically replaced at build time, such as in Next.js or Vite.js projects, which means process.env
is not a standard JavaScript object. In that case, it is equivalent to trying to destructuring from undefined
.
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-no-destructure-process-env
:
npm install eslint-plugin-no-destructure-process-env --save-dev
Add no-destructure-process-env
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["no-destructure-process-env"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"no-destructure-process-env/no-destructure-process-env": 2
}
}
- Fill in provided rules here