简中文档

no-process-global

NOTE: this rule is part of the 推荐 rule set.
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["推荐"]
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{
  "lint": {
    "rules": {
      "include": ["no-process-global"],
      "exclude": ["no-process-global"]
    }
  }
}

禁止使用 NodeJS 的 process 全局变量。

NodeJS 和 Deno 暴露了 process 全局变量,但它们很难被工具进行静态分析,因此代码不应假设它们是可用的。相反,请使用 import process from "node:process"

无效:

// foo.ts
const foo = process.env.FOO;

有效:

// foo.ts
import process from "node:process";

const foo = process.env.FOO;

你找到了你需要的东西吗?

编辑此页面
隐私政策