noProcessGlobal
Summary
Section titled “Summary”- Rule available since:
v2.0.0
- Diagnostic Category:
lint/nursery/noProcessGlobal
- This rule has a safe fix.
- The default severity of this rule is information.
- Sources:
- Same as
deno-lint/no-process-global
- Same as
Description
Section titled “Description”Disallow the use of process
global.
Node.js and Deno expose process
global but they are hard to statically analyze by tools,
so code should not assume they are available. Instead, import process from "node:process"
.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const foo = process.env.FOO;
code-block.js:1:13 lint/nursery/noProcessGlobal FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Usage of the process
global is discouraged.
> 1 │ const foo = process.env.FOO;
│ ^^^^^^^
2 │
ℹ process
global is hard for tools to statically analyze, so code should not assume they are available.
ℹ Safe fix: Add import process from "node:process";
to this file’s imports.
1 │ + import·process·from·“node:process”;
1 2 │ const foo = process.env.FOO;
2 3 │
import process from "node:process";
const foo = process.env.FOO;
The rule is not able to detect cases where the global object is aliased:
const foo = globalThis;const bar = foo.process;
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noProcessGlobal": "error" } } }}