denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.32k stars 5.36k forks source link

Lint: Add a rule for Node built ins not having the `node:` prefix #24930

Open marvinhagemeister opened 3 months ago

marvinhagemeister commented 3 months ago

We should add a lint rule that warns when you're importing Node built-in modules without the node: specifier.

// This should error
import * as fs from "fs"

// This should not error
import * as fs from "node:fs"

Preferable with an integration into deno lint --fix as well.

ry commented 3 months ago

The LSP already errors properly on this but it probably would be better as a lint rule

https://github.com/denoland/deno/blob/9d6da1036d80a29862f6bdfb51e6f51eee235c35/cli/lsp/diagnostics.rs#L1176-L1197