src/content/docs/linter/rules/no-process-env.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.9.1` - Diagnostic Category: [`lint/style/noProcessEnv`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`n/no-process-env`](https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-process-env.md){
"linter": {
"rules": {
"style": {
"noProcessEnv": "error"
}
}
}
}
Disallow the use of process.env.
The process.env object in Node.js stores configuration settings. Using it directly throughout a project can cause problems:
A better practice is to keep all settings in one configuration file and reference it throughout the project.
if (process.env.NODE_ENV === 'development') {
// ...
}
const config = require('./config');
if (config.NODE_ENV === 'development') {
// ...
}