enforce either
process
orrequire("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.
This rule enforces which process
we should use.
This rule has a string option.
{
"node/prefer-global/process": ["error", "always" | "never"]
}
"always"
(default) ... enforces to use the global variableprocess
rather thanrequire("process")
."never"
... enforces to userequire("process")
rather than the global variableprocess
.
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)
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)