Skip to content

Commit

Permalink
feat(lint): add no-process-global lint rule (#25709)
Browse files Browse the repository at this point in the history
Closes #25679
  • Loading branch information
littledivy committed Sep 18, 2024
1 parent f347e77 commit fd86026
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ deno_config = { version = "=0.34.3", features = ["workspace", "sync"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "0.148.0", features = ["html", "syntect"] }
deno_graph = { version = "=0.82.1" }
deno_lint = { version = "=0.66.0", features = ["docs"] }
deno_lint = { version = "=0.67.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm = "=0.25.1"
deno_package_json.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"steps": [
{
"args": "run main.ts",
"output": ""
"output": "main.out",
"exitCode": 1
},
{
"args": "lint main.ts",
Expand Down
12 changes: 6 additions & 6 deletions tests/specs/lint/node_globals_no_duplicate_imports/lint.out
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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


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

Expand Down
4 changes: 4 additions & 0 deletions tests/specs/lint/node_globals_no_duplicate_imports/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: Uncaught (in promise) ReferenceError: setImmediate is not defined
const _foo = setImmediate;
^
at [WILDCARD]main.ts:3:14
4 changes: 2 additions & 2 deletions tests/specs/lint/node_globals_no_duplicate_imports/main.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit fd86026

Please sign in to comment.