Skip to content

Commit 0aad93f

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Use node: scheme to import Node.js builtins
Summary: A stylistic choice to unify on `node:`-prefixed imports, e.g. `fs` -> `node:fs`. **Motivation** Follows D112733139 (Metro): - New Node builtins are *only* available under the prefix (e.g. `node:sqlite`), as this allows Node to introduce them without ecosystem-breaking changes, so this is the direction of travel and the only choice that'll allow consistency. - Encouraging them and grouping them separately makes it easier to reason about a module's 3rd party dependencies. Changelog: [Internal] Differential Revision: D112803684
1 parent 4a66207 commit 0aad93f

277 files changed

Lines changed: 600 additions & 594 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ module.exports = {
1515

1616
extends: ['@react-native'],
1717

18-
plugins: ['@react-native/monorepo', '@react-native/specs'],
18+
plugins: ['@react-native/monorepo', '@react-native/specs', 'import'],
19+
20+
rules: {
21+
'import/enforce-node-protocol-usage': ['warn', 'always'],
22+
},
1923

2024
overrides: [
2125
// overriding the JS config from @react-native/eslint-config to ensure

flow-typed/npm/chrome-launcher_v0.15.x.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010

1111
declare module 'chrome-launcher' {
12-
import typeof fs from 'fs';
13-
import typeof childProcess from 'child_process';
14-
import type {ChildProcess} from 'child_process';
12+
import typeof fs from 'node:fs';
13+
import typeof childProcess from 'node:child_process';
14+
import type {ChildProcess} from 'node:child_process';
1515

1616
declare export type Options = {
1717
startingUrl?: string,

flow-typed/npm/chromium-edge-launcher_v0.2.x.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010

1111
declare module 'chromium-edge-launcher' {
12-
import typeof fs from 'fs';
13-
import typeof childProcess from 'child_process';
14-
import type {ChildProcess} from 'child_process';
12+
import typeof fs from 'node:fs';
13+
import typeof childProcess from 'node:child_process';
14+
import type {ChildProcess} from 'node:child_process';
1515

1616
declare export type Options = {
1717
startingUrl?: string,

flow-typed/npm/connect_v3.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
declare module 'connect' {
12-
import type http from 'http';
12+
import type http from 'node:http';
1313

1414
declare export type ServerHandle = HandleFunction | http.Server;
1515

flow-typed/npm/cross-spawn_v7.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
declare module 'cross-spawn' {
12-
import * as child_process from 'child_process';
12+
import * as child_process from 'node:child_process';
1313

1414
type spawn = typeof child_process.spawn & {
1515
spawn: spawn,

flow-typed/npm/node-fetch_v2.x.x.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/node-fetch_v2.x.x/flow_v0.104.x-/node-fetch_v2.x.x.js
1313

1414
declare module 'node-fetch' {
15-
import type http from 'http';
16-
import type https from 'https';
17-
import type {Readable} from 'stream';
15+
import type http from 'node:http';
16+
import type https from 'node:https';
17+
import type {Readable} from 'node:stream';
1818

1919
declare type AbortSignal = {
2020
+aborted: boolean,

flow-typed/npm/open_v7.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
declare module 'open' {
12-
import type {ChildProcess} from 'child_process';
12+
import type {ChildProcess} from 'node:child_process';
1313

1414
declare export type Options = Readonly<{
1515
wait?: boolean,

flow-typed/npm/serve-static_v1.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
declare module 'serve-static' {
1212
import type {NextHandleFunction} from 'connect';
13-
import type http from 'http';
13+
import type http from 'node:http';
1414

1515
declare export type Options = Readonly<{
1616
/**

flow-typed/npm/tinyglobby_v0.2.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'tinyglobby' {
2-
import typeof FSModule from 'fs';
2+
import typeof FSModule from 'node:fs';
33

44
declare type FileSystemAdapter = Partial<FSModule>;
55

packages/babel-plugin-codegen/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
let FlowParser, TypeScriptParser, RNCodegen;
1414

1515
const {cheap: traverseCheap} = require('@babel/traverse').default;
16-
const {basename} = require('path');
16+
const {basename} = require('node:path');
1717

1818
try {
1919
FlowParser =

0 commit comments

Comments
 (0)