Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1.01 KB

no-node-env.md

File metadata and controls

33 lines (25 loc) · 1.01 KB

Disallow use of process.env.NODE_ENV during SSR (lwc/ssr/no-node-env)

Using process.env.NODE_ENV during server-side rendering in JavaScript is not recommended because it can introduce unexpected behavior and bugs in your application. This environment variable is typically used for conditional logic related to development or production builds, which is more relevant on the client side.

Rule Details

Example of incorrect code for this rule:

import { LightningElement } from 'lwc';

export default class Foo extends LightningElement {
    connectedCallback() {
        if (process.env.NODE_ENV !== 'production') {
            console.log('Foo:connectedCallback');
        }
    }
}

Examples of correct code for this rule:

import { LightningElement } from 'lwc';

export default class Foo extends LightningElement {
    connectedCallback() {
        if (!import.meta.env.SSR && process.env.NODE_ENV !== 'production') {
            console.log('Foo:connectedCallback');
        }
    }
}