no-node-globals
NOTE: this rule is part of the
recommended
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["recommended"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
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-node-globals"], "exclude": ["no-node-globals"] } } }
Disallows the use of NodeJS global objects.
NodeJS exposes a set of global objects that differs from deno (and the web), so code should not assume they are available. Instead, import the objects from their defining modules as needed.
Invalid:
// foo.ts
const buf = Buffer.from("foo", "utf-8"); // Buffer is not a global object in deno
Valid:
// foo.ts
import { Buffer } from "node:buffer";
const foo = Buffer.from("foo", "utf-8");