Skip to content

Latest commit

 

History

History
70 lines (45 loc) · 1.42 KB

File metadata and controls

70 lines (45 loc) · 1.42 KB

node/prefer-global/process

enforce either process or require("process")

The process module is defined as a global variable.

process.log(process === require("process")) //→ true

It will be readable if we use either process consistently.

📖 Rule Details

This rule enforces which process we should use.

Options

This rule has a string option.

{
    "node/prefer-global/process": ["error", "always" | "never"]
}
  • "always" (default) ... enforces to use the global variable process rather than require("process").
  • "never" ... enforces to use require("process") rather than the global variable process.

always

Examples of 👎 incorrect code for this rule:

/*eslint node/prefer-global/process: [error]*/

const process = require("process")
process.exit(0)

Examples of 👍 correct code for this rule:

/*eslint node/prefer-global/process: [error]*/

process.exit(0)

never

Examples of 👎 incorrect code for the "never" option:

/*eslint node/prefer-global/process: [error, never]*/

process.exit(0)

Examples of 👍 correct code for the "never" option:

/*eslint node/prefer-global/process: [error, never]*/

const process = require("process")
process.exit(0)

🔎 Implementation