Skip to content

Change Request: Add option to allow NODE_ENV in n/no-process-env #283

Closed
@alecmev

Description

@alecmev

eslint-plugin-n version

17.7.0

What problem do you want to solve?

It's common for bundlers to inline process.env.NODE_ENV and such, so that minifiers can do their job and eliminate dead code. Currently n/no-process-env takes issue with every use of process.env.NODE_ENV and I have to disable it manually. I don't want to disable it completely as I still want to encourage configuration validation. I can't import nodeEnv from ./config.js or something because some (all?) minifiers don't dig that far and will not eliminate any code wrapped in if (nodeEnv === "production") ....

What do you think is the correct solution?

Options:

  1. Add allowNodeEnv, defaulting to false. Probably a bit simpler to implement and covers the majority of cases.
  2. Add allowlist, defaulting to []. NODE_ENV is the behemoth, but there's a long tail of other variables.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions