GeezerVison is showing github.com — doc,tools: enforce use of `node:` prefix · nodejs/node@44a08f7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/async_hooks.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -704,7 +704,7 @@ import { | 704 | 704 | executionAsyncId, | 705 | 705 | executionAsyncResource, | 706 | 706 | createHook, | 707 | | -} from 'async_hooks'; | | 707 | +} from 'node:async_hooks'; | 708 | 708 | const sym = Symbol('state'); // Private symbol to avoid pollution | 709 | 709 |
| 710 | 710 | createHook({ | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/timers.md +4-4Lines changed: 4 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -378,7 +378,7 @@ import { | 378 | 378 | setTimeout, | 379 | 379 | setImmediate, | 380 | 380 | setInterval, | 381 | | -} from 'timers/promises'; | | 381 | +} from 'node:timers/promises'; | 382 | 382 | ``` | 383 | 383 |
| 384 | 384 | ```cjs | @@ -408,7 +408,7 @@ added: v15.0.0 | 408 | 408 | ```mjs | 409 | 409 | import { | 410 | 410 | setTimeout, | 411 | | -} from 'timers/promises'; | | 411 | +} from 'node:timers/promises'; | 412 | 412 |
| 413 | 413 | const res = await setTimeout(100, 'result'); | 414 | 414 |
| @@ -442,7 +442,7 @@ added: v15.0.0 | 442 | 442 | ```mjs | 443 | 443 | import { | 444 | 444 | setImmediate, | 445 | | -} from 'timers/promises'; | | 445 | +} from 'node:timers/promises'; | 446 | 446 |
| 447 | 447 | const res = await setImmediate('result'); | 448 | 448 |
| @@ -483,7 +483,7 @@ or implicitly to keep the event loop alive. | 483 | 483 | ```mjs | 484 | 484 | import { | 485 | 485 | setInterval, | 486 | | -} from 'timers/promises'; | | 486 | +} from 'node:timers/promises'; | 487 | 487 |
| 488 | 488 | const interval = 100; | 489 | 489 | for await (const startTime of setInterval(interval, Date.now())) { | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/wasi.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,7 @@ operating system via a collection of POSIX-like functions. | 17 | 17 |
| 18 | 18 | ```mjs | 19 | 19 | import { readFile } from 'node:fs/promises'; | 20 | | -import { WASI } from 'wasi'; | | 20 | +import { WASI } from 'node:wasi'; | 21 | 21 | import { argv, env } from 'node:process'; | 22 | 22 |
| 23 | 23 | const wasi = new WASI({ | @@ -40,7 +40,7 @@ wasi.start(instance); | 40 | 40 | ```cjs | 41 | 41 | 'use strict'; | 42 | 42 | const { readFile } = require('node:fs/promises'); | 43 | | -const { WASI } = require('wasi'); | | 43 | +const { WASI } = require('node:wasi'); | 44 | 44 | const { argv, env } = require('node:process'); | 45 | 45 | const { join } = require('node:path'); | 46 | 46 |
| |
Collapse file Copy file name to clipboardExpand all lines: doc/api/worker_threads.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1455,7 +1455,7 @@ Node.js event loop. | 1455 | 1455 | import { | 1456 | 1456 | Worker, | 1457 | 1457 | isMainThread, | 1458 | | -} from 'worker_threads'; | | 1458 | +} from 'node:worker_threads'; | 1459 | 1459 |
| 1460 | 1460 | if (isMainThread) { | 1461 | 1461 | new Worker(new URL(import.meta.url)); | |
Collapse file Copy file name to clipboardExpand all lines: doc/eslint.config_partial.mjs +15-1Lines changed: 15 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { requireEslintTool } from '../tools/eslint/eslint.config_utils.mjs'; | | 1 | +import { | | 2 | + noRestrictedSyntaxCommonAll, | | 3 | + noRestrictedSyntaxCommonLib, | | 4 | + requireEslintTool, | | 5 | +} from '../tools/eslint/eslint.config_utils.mjs'; | | 6 | +import { builtinModules as builtin } from 'node:module'; | 2 | 7 |
| 3 | 8 | const globals = requireEslintTool('globals'); | 4 | 9 |
| @@ -8,6 +13,15 @@ export default [ | 8 | 13 | rules: { | 9 | 14 | // Ease some restrictions in doc examples. | 10 | 15 | 'no-restricted-properties': 'off', | | 16 | + 'no-restricted-syntax': [ | | 17 | + 'error', | | 18 | + ...noRestrictedSyntaxCommonAll, | | 19 | + ...noRestrictedSyntaxCommonLib, | | 20 | + { | | 21 | + selector: `CallExpression[callee.name="require"][arguments.0.type="Literal"]:matches(${builtin.map((name) => `[arguments.0.value="${name}"]`).join(',')}),ImportDeclaration:matches(${builtin.map((name) => `[source.value="${name}"]`).join(',')})`, | | 22 | + message: 'Use `node:` prefix.', | | 23 | + }, | | 24 | + ], | 11 | 25 | 'no-undef': 'off', | 12 | 26 | 'no-unused-expressions': 'off', | 13 | 27 | 'no-unused-vars': 'off', | |
|