1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 17:49:08 -05:00
denoland-deno/tests/specs/lint
Nathan Whitaker 5ec3c5c3a4
feat(lint): Add lint for usage of node globals (with autofix) (#25048)
From upgrading `deno_lint`.

Previously if you had a node project that used a bunch of node globals
(`process.env`, etc), you would have to fix the errors by hand. This PR
includes a new lint that detects usages of node globals (`process`,
`setImmediate`, `Buffer`, etc.) and provides an autofix to import the
correct value. For instance:

```ts
// main.ts
const _foo = process.env.FOO;
```

`deno lint` gives you

```ts
error[no-node-globals]: NodeJS globals are not available in Deno
 --> /home/foo.ts:1:14
  |
1 | const _foo = process.env.FOO;
  |              ^^^^^^^
  = hint: Add `import process from "node:process";`

  docs: https://lint.deno.land/rules/no-node-globals


Found 1 problem (1 fixable via --fix)
Checked 1 file
```
And `deno lint --fix` adds the import for you:

```ts
// main.ts
import process from "node:process";
const _foo = process.env.FOO;
```
2024-08-15 20:43:04 +00:00
..
bom fix: do not panic linting files with UTF-8 BOM (#24136) 2024-06-07 17:02:47 +00:00
jsr_tag feat(lint): automatically opt-in packages to jsr lint tag (#23072) 2024-03-25 18:20:15 -04:00
lint_fix feat(lint): deno lint --fix and lsp quick fixes (#22615) 2024-03-21 14:18:59 -07:00
no_slow_types fix: better handling of npm resolution occurring on workers (#24094) 2024-06-05 17:04:16 +02:00
no_slow_types_entrypoint fix: better handling of npm resolution occurring on workers (#24094) 2024-06-05 17:04:16 +02:00
no_slow_types_workspace feat: npm workspace and better Deno workspace support (#24334) 2024-07-04 00:54:33 +00:00
node_globals_no_duplicate_imports feat(lint): Add lint for usage of node globals (with autofix) (#25048) 2024-08-15 20:43:04 +00:00
sloppy_imports_dts fix(unstable): move sloppy-import warnings to lint rule (#24710) 2024-07-25 09:07:59 -04:00
sloppy_imports_no_incremental_cache fix(unstable): move sloppy-import warnings to lint rule (#24710) 2024-07-25 09:07:59 -04:00
syntax_error_reporting fix: enable the reporting of parsing related problems when running deno lint (#24332) 2024-07-23 21:17:17 +00:00
workspace feat: npm workspace and better Deno workspace support (#24334) 2024-07-04 00:54:33 +00:00
workspace_no_slow_types feat: npm workspace and better Deno workspace support (#24334) 2024-07-04 00:54:33 +00:00