enforce either
consoleorrequire("console")
The console module is defined as a global variable.
console.log(console === require("console")) //β trueIt will be readable if we use either console consistently.
This rule enforces which console we should use.
This rule has a string option.
{
"node/prefer-global/console": ["error", "always" | "never"]
}"always"(default) ... enforces to use the global variableconsolerather thanrequire("console")."never"... enforces to userequire("console")rather than the global variableconsole.
Examples of π incorrect code for this rule:
/*eslint node/prefer-global/console: [error]*/
const console = require("console")
console.log("hello")Examples of π correct code for this rule:
/*eslint node/prefer-global/console: [error]*/
console.log("hello")Examples of π incorrect code for the "never" option:
/*eslint node/prefer-global/console: [error, never]*/
console.log("hello")Examples of π correct code for the "never" option:
/*eslint node/prefer-global/console: [error, never]*/
const console = require("console")
console.log("hello")