feat(lint): add no-process-global lint rule (#25709)

Closes https://github.com/denoland/deno/issues/25679
This commit is contained in:
Divy Srivastava 2024-09-19 00:20:42 +05:30 committed by GitHub
parent f347e779e0
commit fd860260ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 12 deletions

View file

@ -3,7 +3,8 @@
"steps": [
{
"args": "run main.ts",
"output": ""
"output": "main.out",
"exitCode": 1
},
{
"args": "lint main.ts",

View file

@ -1,9 +1,9 @@
error[no-node-globals]: NodeJS globals are not available in Deno
--> [WILDCARD]main.ts:3:14
|
3 | const _foo = process.env.FOO;
| ^^^^^^^
= hint: Add `import process from "node:process";`
3 | const _foo = setImmediate;
| ^^^^^^^^^^^^
= hint: Add `import { setImmediate } from "node:timers";`
docs: https://lint.deno.land/rules/no-node-globals
@ -11,9 +11,9 @@ error[no-node-globals]: NodeJS globals are not available in Deno
error[no-node-globals]: NodeJS globals are not available in Deno
--> [WILDCARD]main.ts:7:14
|
7 | const _bar = process.env.BAR;
| ^^^^^^^
= hint: Add `import process from "node:process";`
7 | const _bar = setImmediate;
| ^^^^^^^^^^^^
= hint: Add `import { setImmediate } from "node:timers";`
docs: https://lint.deno.land/rules/no-node-globals

View file

@ -0,0 +1,4 @@
error: Uncaught (in promise) ReferenceError: setImmediate is not defined
const _foo = setImmediate;
^
at [WILDCARD]main.ts:3:14

View file

@ -1,7 +1,7 @@
import {} from "node:console";
const _foo = process.env.FOO;
const _foo = setImmediate;
import {} from "node:assert";
const _bar = process.env.BAR;
const _bar = setImmediate;