コンテンツにスキップ

noProcessGlobal

このコンテンツはまだ日本語訳がありません。

biome.json
{
"linter": {
"rules": {
"correctness": {
"noProcessGlobal": "error"
}
}
}
}

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".

const foo = process.env.FOO;
code-block.js:1:13 lint/correctness/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;