diff --git a/js/.eslintrc.cjs b/js/.eslintrc.cjs index 8a36516eec1..1792a33abae 100644 --- a/js/.eslintrc.cjs +++ b/js/.eslintrc.cjs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +/** @type {import('eslint').Linter.Config} */ module.exports = { env: { browser: true, @@ -25,7 +26,7 @@ module.exports = { parserOptions: { project: ["tsconfig.json", "tsconfig/tsconfig.bin.cjs.json"], sourceType: "module", - ecmaVersion: 2020, + ecmaVersion: "latest", }, plugins: ["@typescript-eslint", "jest", "unicorn"], extends: [ @@ -92,16 +93,13 @@ module.exports = { "unicorn/empty-brace-spaces": "off", "unicorn/no-zero-fractions": "off", "unicorn/prevent-abbreviations": "off", - "unicorn/prefer-module": "off", "unicorn/numeric-separators-style": "off", "unicorn/prefer-spread": "off", "unicorn/filename-case": "off", "unicorn/prefer-export-from": "off", "unicorn/prefer-switch": "off", - "unicorn/prefer-node-protocol": "off", "unicorn/text-encoding-identifier-case": "off", "unicorn/prefer-top-level-await": "off", - "unicorn/consistent-destructuring": "off", "unicorn/no-array-reduce": "off", "unicorn/no-await-expression-member": "off", diff --git a/js/bin/file-to-stream.ts b/js/bin/file-to-stream.ts index 9dad4951f96..b7341faf2c0 100755 --- a/js/bin/file-to-stream.ts +++ b/js/bin/file-to-stream.ts @@ -17,9 +17,9 @@ // specific language governing permissions and limitations // under the License. -import * as fs from 'fs'; -import * as Path from 'path'; -import { finished as eos } from 'stream/promises'; +import * as fs from 'node:fs'; +import * as Path from 'node:path'; +import { finished as eos } from 'node:stream/promises'; import { RecordBatchReader, RecordBatchStreamWriter } from '../index.ts'; (async () => { diff --git a/js/bin/integration.ts b/js/bin/integration.ts index f9aad3422ae..f73388cc85c 100755 --- a/js/bin/integration.ts +++ b/js/bin/integration.ts @@ -17,8 +17,8 @@ // specific language governing permissions and limitations // under the License. -import * as fs from 'fs'; -import * as Path from 'path'; +import * as fs from 'node:fs'; +import * as Path from 'node:path'; import { glob } from 'glob'; import { zip } from 'ix/iterable/zip.js'; import commandLineArgs from 'command-line-args'; @@ -41,8 +41,8 @@ const argv = commandLineArgs(cliOpts(), { partial: true }); const exists = async (p: string) => { try { return !!(await fs.promises.stat(p)); - } catch (e) { return false; } -} + } catch { return false; } +}; (async () => { @@ -52,17 +52,17 @@ const exists = async (p: string) => { let jsonPaths = [...(argv.json || [])]; let arrowPaths = [...(argv.arrow || [])]; - if (mode === 'VALIDATE' && !jsonPaths.length) { + if (mode === 'VALIDATE' && jsonPaths.length === 0) { [jsonPaths, arrowPaths] = await loadLocalJSONAndArrowPathsForDebugging(jsonPaths, arrowPaths); } - if (!jsonPaths.length) { return print_usage(); } + if (jsonPaths.length === 0) { return print_usage(); } let threw = false; switch (mode) { case 'VALIDATE': - for (let [jsonPath, arrowPath] of zip(jsonPaths, arrowPaths)) { + for (const [jsonPath, arrowPath] of zip(jsonPaths, arrowPaths)) { try { await validate(jsonPath, arrowPath); } catch (e: any) { @@ -232,7 +232,7 @@ function compareVectors(actual: Vector, expected: Vector) { (() => { let i = -1; - for (let [x1, x2] of zip(actual, expected)) { + for (const [x1, x2] of zip(actual, expected)) { ++i; if (!createElementComparator(x2)(x1)) { throw new Error(`${i}: ${x1} !== ${x2}`); @@ -245,14 +245,14 @@ async function loadLocalJSONAndArrowPathsForDebugging(jsonPaths: string[], arrow const sourceJSONPaths = await glob(Path.resolve(__dirname, `../test/data/json/`, `*.json`)); - if (!arrowPaths.length) { + if (arrowPaths.length === 0) { await loadJSONAndArrowPaths(sourceJSONPaths, jsonPaths, arrowPaths, 'cpp', 'file'); await loadJSONAndArrowPaths(sourceJSONPaths, jsonPaths, arrowPaths, 'java', 'file'); await loadJSONAndArrowPaths(sourceJSONPaths, jsonPaths, arrowPaths, 'cpp', 'stream'); await loadJSONAndArrowPaths(sourceJSONPaths, jsonPaths, arrowPaths, 'java', 'stream'); } - for (let [jsonPath, arrowPath] of zip(jsonPaths, arrowPaths)) { + for (const [jsonPath, arrowPath] of zip(jsonPaths, arrowPaths)) { console.log(`jsonPath: ${jsonPath}`); console.log(`arrowPath: ${arrowPath}`); } diff --git a/js/bin/json-to-arrow.ts b/js/bin/json-to-arrow.ts index 49726706a1b..168db00a54f 100755 --- a/js/bin/json-to-arrow.ts +++ b/js/bin/json-to-arrow.ts @@ -17,10 +17,10 @@ // specific language governing permissions and limitations // under the License. -import * as fs from 'fs'; -import * as Path from 'path'; +import * as fs from 'node:fs'; +import * as Path from 'node:path'; import commandLineArgs from 'command-line-args'; -import { finished as eos } from 'stream/promises'; +import { finished as eos } from 'node:stream/promises'; // @ts-ignore import { parse as bignumJSONParse } from 'json-bignum'; import { RecordBatchReader, RecordBatchFileWriter, RecordBatchStreamWriter } from '../index.ts'; @@ -31,7 +31,7 @@ const arrowPaths = [...(argv.arrow || [])]; (async () => { - if (!jsonPaths.length || !arrowPaths.length || (jsonPaths.length !== arrowPaths.length)) { + if (jsonPaths.length === 0 || arrowPaths.length === 0 || (jsonPaths.length !== arrowPaths.length)) { return print_usage(); } @@ -51,7 +51,7 @@ const arrowPaths = [...(argv.arrow || [])]; await eos(jsonToArrow); })); - return undefined; + return; })() .then((x) => x ?? 0, (e) => { e && process.stderr.write(`${e}`); diff --git a/js/bin/print-buffer-alignment.ts b/js/bin/print-buffer-alignment.ts index 07563af5a87..dabe3c5f9ab 100755 --- a/js/bin/print-buffer-alignment.ts +++ b/js/bin/print-buffer-alignment.ts @@ -17,8 +17,8 @@ // specific language governing permissions and limitations // under the License. -import * as fs from 'fs'; -import * as Path from 'path'; +import * as fs from 'node:fs'; +import * as Path from 'node:path'; import { VectorLoader } from '../src/visitor/vectorloader.ts'; import { RecordBatch, AsyncMessageReader, makeData, Struct, Schema, Field } from '../index.ts'; diff --git a/js/bin/stream-to-file.ts b/js/bin/stream-to-file.ts index 6e09ead2fde..c1317abc975 100755 --- a/js/bin/stream-to-file.ts +++ b/js/bin/stream-to-file.ts @@ -17,9 +17,9 @@ // specific language governing permissions and limitations // under the License. -import * as fs from 'fs'; -import * as path from 'path'; -import { finished as eos } from 'stream/promises'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import { finished as eos } from 'node:stream/promises'; import { RecordBatchReader, RecordBatchFileWriter } from '../index.ts'; (async () => { diff --git a/js/gulp/arrow-task.js b/js/gulp/arrow-task.js index f8a18fe122a..855cb712837 100644 --- a/js/gulp/arrow-task.js +++ b/js/gulp/arrow-task.js @@ -18,9 +18,9 @@ import { mainExport, targetDir, observableFromStreams } from './util.js'; import gulp from 'gulp'; -import path from 'path'; +import path from 'node:path'; import { mkdirp } from 'mkdirp'; -import * as fs from 'fs/promises'; +import * as fs from 'node:fs/promises'; import gulpRename from 'gulp-rename'; import gulpReplace from 'gulp-replace'; import { memoizeTask } from './memoize-task.js'; diff --git a/js/gulp/bundle-task.js b/js/gulp/bundle-task.js index 41a0895b082..b0aab6c468e 100644 --- a/js/gulp/bundle-task.js +++ b/js/gulp/bundle-task.js @@ -23,9 +23,9 @@ import source from 'vinyl-source-stream'; import buffer from 'vinyl-buffer'; import { observableFromStreams } from './util.js'; import { forkJoin as ObservableForkJoin } from 'rxjs'; -import { resolve, join } from 'path'; -import { readdirSync } from 'fs'; -import { execSync } from 'child_process'; +import { resolve, join } from 'node:path'; +import { readdirSync } from 'node:fs'; +import { execSync } from 'node:child_process'; import gulpEsbuild from 'gulp-esbuild'; import esbuildAlias from 'esbuild-plugin-alias'; @@ -38,8 +38,8 @@ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; import webpack from 'webpack-stream'; import named from 'vinyl-named'; -import { fileURLToPath } from 'url'; -import { dirname } from 'path'; +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/js/gulp/closure-task.js b/js/gulp/closure-task.js index 7c0ae1c1b6c..c620784fd1a 100644 --- a/js/gulp/closure-task.js +++ b/js/gulp/closure-task.js @@ -17,9 +17,9 @@ import { targetDir, mainExport, esmRequire, gCCLanguageNames, publicModulePaths, observableFromStreams, shouldRunInChildProcess, spawnGulpCommandInChildProcess } from "./util.js"; -import fs from 'fs'; +import fs from 'node:fs'; import gulp from 'gulp'; -import path from 'path'; +import path from 'node:path'; import { mkdirp } from 'mkdirp'; import sourcemaps from 'gulp-sourcemaps'; import { memoizeTask } from './memoize-task.js'; diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index 5d190be22d5..e2263049b3d 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -16,14 +16,14 @@ // under the License. import { deleteAsync as del } from 'del'; -import path from 'path'; +import path from 'node:path'; import { mkdirp } from 'mkdirp'; import { argv } from './argv.js'; -import { promisify } from 'util'; +import { promisify } from 'node:util'; import { glob } from 'glob'; -import child_process from 'child_process'; +import child_process from 'node:child_process'; import { memoizeTask } from './memoize-task.js'; -import fs from 'fs'; +import fs from 'node:fs'; const readFile = promisify(fs.readFile); import asyncDoneSync from 'async-done'; const asyncDone = promisify(asyncDoneSync); @@ -31,7 +31,7 @@ const exec = promisify(child_process.exec); import xml2js from 'xml2js'; const parseXML = promisify(xml2js.parseString); import { targetAndModuleCombinations, npmPkgName } from './util.js'; -import { createRequire } from 'module'; +import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); diff --git a/js/gulp/typescript-task.js b/js/gulp/typescript-task.js index 31769e3b1b2..b5a4c3232dc 100644 --- a/js/gulp/typescript-task.js +++ b/js/gulp/typescript-task.js @@ -18,10 +18,10 @@ import { targetDir, tsconfigName, observableFromStreams, shouldRunInChildProcess, spawnGulpCommandInChildProcess } from './util.js'; import gulp from 'gulp'; -import path from 'path'; +import path from 'node:path'; import tsc from 'typescript'; import ts from 'gulp-typescript'; -import * as fs from 'fs/promises'; +import * as fs from 'node:fs/promises'; import sourcemaps from 'gulp-sourcemaps'; import { memoizeTask } from './memoize-task.js'; import { ReplaySubject, forkJoin as ObservableForkJoin, defer as ObservableDefer } from 'rxjs'; diff --git a/js/gulp/util.js b/js/gulp/util.js index d86011008ad..2ce756f4aca 100644 --- a/js/gulp/util.js +++ b/js/gulp/util.js @@ -15,18 +15,18 @@ // specific language governing permissions and limitations // under the License. -import fs from 'fs'; -import path from 'path'; -import child_process from 'child_process'; -import stream from 'stream'; -import util from 'util'; +import fs from 'node:fs'; +import path from 'node:path'; +import child_process from 'node:child_process'; +import stream from 'node:stream'; +import util from 'node:util'; import asyncDoneSync from 'async-done'; const pump = stream.pipeline; import { targets, modules } from './argv.js'; import { ReplaySubject, empty as ObservableEmpty, throwError as ObservableThrow, fromEvent as ObservableFromEvent } from 'rxjs'; import { share, flatMap, takeUntil, defaultIfEmpty, mergeWith } from 'rxjs/operators'; const asyncDone = util.promisify(asyncDoneSync); -import { createRequire } from 'module'; +import { createRequire } from 'node:module'; import esmRequire from './esm-require.cjs' const require = createRequire(import.meta.url); diff --git a/js/src/bin/arrow2csv.ts b/js/src/bin/arrow2csv.ts index 4115f30099f..569e419faab 100755 --- a/js/src/bin/arrow2csv.ts +++ b/js/src/bin/arrow2csv.ts @@ -19,8 +19,8 @@ /* eslint-disable unicorn/no-array-for-each */ -import * as fs from 'fs'; -import * as stream from 'stream'; +import * as fs from 'node:fs'; +import * as stream from 'node:stream'; import { Schema, RecordBatch, RecordBatchReader, AsyncByteQueue, util } from '../Arrow.js'; import * as commandLineUsage from 'command-line-usage'; diff --git a/js/src/builder.ts b/js/src/builder.ts index 1880db3818c..5ae43a88367 100644 --- a/js/src/builder.ts +++ b/js/src/builder.ts @@ -27,6 +27,11 @@ import { import { createIsValidFunction } from './builder/valid.js'; import { BufferBuilder, BitmapBufferBuilder, DataBufferBuilder, OffsetsBufferBuilder } from './builder/buffer.js'; +import type { BuilderDuplexOptions } from './io/node/builder.js'; +import type { BuilderTransform, BuilderTransformOptions } from './io/whatwg/builder.js'; + +import type { Duplex } from 'node:stream'; + /** * A set of options required to create a `Builder` instance for a given `DataType`. * @see {@link Builder} @@ -98,12 +103,12 @@ export abstract class Builder { /** @nocollapse */ // @ts-ignore - public static throughNode(options: import('./io/node/builder').BuilderDuplexOptions): import('stream').Duplex { + public static throughNode(options: BuilderDuplexOptions): Duplex { throw new Error(`"throughNode" not available in this environment`); } /** @nocollapse */ // @ts-ignore - public static throughDOM(options: import('./io/whatwg/builder').BuilderTransformOptions): import('./io/whatwg/builder').BuilderTransform { + public static throughDOM(options: BuilderTransformOptions): BuilderTransform { throw new Error(`"throughDOM" not available in this environment`); } diff --git a/js/src/fb/.eslintrc.cjs b/js/src/fb/.eslintrc.cjs index eb0fc1c7cdc..b7fc1c02909 100644 --- a/js/src/fb/.eslintrc.cjs +++ b/js/src/fb/.eslintrc.cjs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +/** @type {import('eslint').Linter.Config} */ module.exports = { rules: { "@typescript-eslint/type-annotation-spacing": "off", diff --git a/js/src/io/adapters.ts b/js/src/io/adapters.ts index 05020314aa6..3118cba049d 100644 --- a/js/src/io/adapters.ts +++ b/js/src/io/adapters.ts @@ -25,6 +25,8 @@ import { import { ReadableDOMStreamOptions } from './interfaces.js'; +import type { ReadableOptions, Readable } from 'node:stream'; + type Uint8ArrayGenerator = Generator; type AsyncUint8ArrayGenerator = AsyncGenerator; @@ -47,7 +49,7 @@ export default { throw new Error(`"toDOMStream" not available in this environment`); }, // @ts-ignore - toNodeStream(source: Iterable | AsyncIterable, options?: import('stream').ReadableOptions): import('stream').Readable { + toNodeStream(source: Iterable | AsyncIterable, options?: ReadableOptions): Readable { throw new Error(`"toNodeStream" not available in this environment`); }, }; @@ -71,7 +73,7 @@ function* fromIterable(source: Iterable | T): } // Yield so the caller can inject the read command before creating the source Iterator - ({ cmd, size } = (yield (() => null)()) || {cmd: 'read', size: 0}); + ({ cmd, size } = (yield (() => null)()) || { cmd: 'read', size: 0 }); // initialize the iterator const it = toUint8ArrayIterator(source)[Symbol.iterator](); @@ -117,7 +119,7 @@ async function* fromAsyncIterable(source: AsyncI } // Yield so the caller can inject the read command before creating the source AsyncIterator - ({ cmd, size } = (yield (() => null)()) || {cmd: 'read', size: 0}); + ({ cmd, size } = (yield (() => null)()) || { cmd: 'read', size: 0 }); // initialize the iterator const it = toUint8ArrayAsyncIterator(source)[Symbol.asyncIterator](); @@ -167,7 +169,7 @@ async function* fromDOMStream(source: ReadableSt } // Yield so the caller can inject the read command before we establish the ReadableStream lock - ({ cmd, size } = (yield (() => null)()) || {cmd: 'read', size: 0}); + ({ cmd, size } = (yield (() => null)()) || { cmd: 'read', size: 0 }); // initialize the reader and lock the stream const it = new AdaptiveByteReader(source); @@ -273,7 +275,7 @@ async function* fromNodeStream(stream: NodeJS.ReadableStream): AsyncUint8ArrayGe // Yield so the caller can inject the read command before we // add the listener for the source stream's 'readable' event. - ({ cmd, size } = (yield (() => null)()) || {cmd: 'read', size: 0}); + ({ cmd, size } = (yield (() => null)()) || { cmd: 'read', size: 0 }); // ignore stdin if it's a TTY if ((stream as any)['isTTY']) { diff --git a/js/src/io/interfaces.ts b/js/src/io/interfaces.ts index d69841bcbbb..6775c3240b6 100644 --- a/js/src/io/interfaces.ts +++ b/js/src/io/interfaces.ts @@ -17,11 +17,12 @@ import streamAdapters from './adapters.js'; +export type { FileHandle } from 'node:fs/promises'; +import type { ReadableOptions, Readable as StreamReadable } from 'node:stream'; + /** @ignore */ export const ITERATOR_DONE: any = Object.freeze({ done: true, value: void (0) }); -/** @ignore */ -export type FileHandle = import('fs').promises.FileHandle; /** @ignore */ export type ArrowJSONLike = { schema: any; batches?: any[]; dictionaries?: any[] }; /** @ignore */ @@ -60,14 +61,14 @@ export interface Writable { export interface ReadableWritable extends Readable, Writable { [Symbol.asyncIterator](): AsyncIterableIterator; toDOMStream(options?: ReadableDOMStreamOptions): ReadableStream; - toNodeStream(options?: import('stream').ReadableOptions): import('stream').Readable; + toNodeStream(options?: ReadableOptions): StreamReadable; } /** @ignore */ export abstract class ReadableInterop { public abstract toDOMStream(options?: ReadableDOMStreamOptions): ReadableStream; - public abstract toNodeStream(options?: import('stream').ReadableOptions): import('stream').Readable; + public abstract toNodeStream(options?: ReadableOptions): StreamReadable; public tee(): [ReadableStream, ReadableStream] { return this._getDOMStream().tee(); @@ -85,7 +86,7 @@ export abstract class ReadableInterop { return this._DOMStream || (this._DOMStream = this.toDOMStream()); } - protected _nodeStream?: import('stream').Readable; + protected _nodeStream?: StreamReadable; private _getNodeStream() { return this._nodeStream || (this._nodeStream = this.toNodeStream()); } @@ -144,7 +145,7 @@ export class AsyncQueue extends R : (this._values as any) as Iterable, options); } - public toNodeStream(options?: import('stream').ReadableOptions) { + public toNodeStream(options?: ReadableOptions) { return streamAdapters.toNodeStream( (this._closedPromiseResolve || this._error) ? (this as AsyncIterable) diff --git a/js/src/io/node/builder.ts b/js/src/io/node/builder.ts index be289f447f5..1d02febac7b 100644 --- a/js/src/io/node/builder.ts +++ b/js/src/io/node/builder.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { Duplex } from 'stream'; +import { Duplex } from 'node:stream'; import { DataType } from '../../type.js'; import { Builder, BuilderOptions } from '../../builder.js'; import { makeBuilder } from '../../factories.js'; diff --git a/js/src/io/node/iterable.ts b/js/src/io/node/iterable.ts index 6698e7fa929..67b2143ea24 100644 --- a/js/src/io/node/iterable.ts +++ b/js/src/io/node/iterable.ts @@ -15,11 +15,11 @@ // specific language governing permissions and limitations // under the License. -import { Readable } from 'stream'; +import { Readable, ReadableOptions as ReadableOptions_ } from 'node:stream'; import { isIterable, isAsyncIterable } from '../../util/compat.js'; /** @ignore */ -type ReadableOptions = import('stream').ReadableOptions; +type ReadableOptions = ReadableOptions_; /** @ignore */ type SourceIterator = Generator; /** @ignore */ diff --git a/js/src/io/node/reader.ts b/js/src/io/node/reader.ts index e8bbf736aa6..77e1fc26e2f 100644 --- a/js/src/io/node/reader.ts +++ b/js/src/io/node/reader.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { Duplex, DuplexOptions } from 'stream'; +import { Duplex, DuplexOptions } from 'node:stream'; import { AsyncByteQueue } from '../../io/stream.js'; import { RecordBatchReader } from '../../ipc/reader.js'; import { RecordBatch } from '../../recordbatch.js'; diff --git a/js/src/io/node/writer.ts b/js/src/io/node/writer.ts index 5725ef7a5d7..fb426a96811 100644 --- a/js/src/io/node/writer.ts +++ b/js/src/io/node/writer.ts @@ -15,7 +15,8 @@ // specific language governing permissions and limitations // under the License. -import { Duplex, DuplexOptions } from 'stream'; +import { Duplex } from 'node:stream'; +import type { DuplexOptions } from 'node:stream'; import { AsyncByteStream } from '../../io/stream.js'; import { RecordBatchWriter } from '../../ipc/writer.js'; import { TypeMap } from '../../type.js'; diff --git a/js/src/ipc/reader.ts b/js/src/ipc/reader.ts index e4dac0606aa..547739dacce 100644 --- a/js/src/ipc/reader.ts +++ b/js/src/ipc/reader.ts @@ -47,6 +47,8 @@ import { isReadableDOMStream, isReadableNodeStream } from '../util/compat.js'; +import type { DuplexOptions, Duplex } from 'node:stream'; + /** @ignore */ export type FromArg0 = ArrowJSONLike; /** @ignore */ export type FromArg1 = PromiseLike; /** @ignore */ export type FromArg2 = Iterable | ArrayBufferViewInput; @@ -129,7 +131,7 @@ export class RecordBatchReader extends ReadableInterop< /** @nocollapse */ // @ts-ignore - public static throughNode(options?: import('stream').DuplexOptions & { autoDestroy: boolean }): import('stream').Duplex { + public static throughNode(options?: DuplexOptions & { autoDestroy: boolean }): Duplex { throw new Error(`"throughNode" not available in this environment`); } /** @nocollapse */ diff --git a/js/src/ipc/writer.ts b/js/src/ipc/writer.ts index 565b0825bd9..8d924ab64c8 100644 --- a/js/src/ipc/writer.ts +++ b/js/src/ipc/writer.ts @@ -35,6 +35,8 @@ import { RecordBatch, _InternalEmptyPlaceholderRecordBatch } from '../recordbatc import { Writable, ReadableInterop, ReadableDOMStreamOptions } from '../io/interfaces.js'; import { isPromise, isAsyncIterable, isWritableDOMStream, isWritableNodeStream, isIterable, isObject } from '../util/compat.js'; +import type { DuplexOptions, Duplex, ReadableOptions } from 'node:stream'; + export interface RecordBatchStreamWriterOptions { /** * @@ -53,7 +55,7 @@ export class RecordBatchWriter extends ReadableInterop< /** @nocollapse */ // @ts-ignore - public static throughNode(options?: import('stream').DuplexOptions & { autoDestroy: boolean }): import('stream').Duplex { + public static throughNode(options?: DuplexOptions & { autoDestroy: boolean }): Duplex { throw new Error(`"throughNode" not available in this environment`); } /** @nocollapse */ @@ -111,7 +113,7 @@ export class RecordBatchWriter extends ReadableInterop< public get closed() { return this._sink.closed; } public [Symbol.asyncIterator]() { return this._sink[Symbol.asyncIterator](); } public toDOMStream(options?: ReadableDOMStreamOptions) { return this._sink.toDOMStream(options); } - public toNodeStream(options?: import('stream').ReadableOptions) { return this._sink.toNodeStream(options); } + public toNodeStream(options?: ReadableOptions) { return this._sink.toNodeStream(options); } public close() { return this.reset()._sink.close(); diff --git a/js/src/util/compat.ts b/js/src/util/compat.ts index 0948e8bea2f..73af3087eae 100644 --- a/js/src/util/compat.ts +++ b/js/src/util/compat.ts @@ -17,12 +17,14 @@ import { ReadableInterop, ArrowJSONLike } from '../io/interfaces.js'; -/* eslint-disable unicorn/throw-new-error */ +import type { ByteBuffer } from 'flatbuffers'; +import type { ReadStream } from 'node:fs'; +import type { FileHandle as FileHandle_ } from 'node:fs/promises'; /** @ignore */ -type FSReadStream = import('fs').ReadStream; +type FSReadStream = ReadStream; /** @ignore */ -type FileHandle = import('fs').promises.FileHandle; +type FileHandle = FileHandle_; /** @ignore */ export interface Subscription { @@ -145,7 +147,7 @@ export const isReadableNodeStream = (x: any): x is NodeJS.ReadableStream => { }; /** @ignore */ -export const isFlatbuffersByteBuffer = (x: any): x is import('flatbuffers').ByteBuffer => { +export const isFlatbuffersByteBuffer = (x: any): x is ByteBuffer => { return isObject(x) && isFunction(x['clear']) && isFunction(x['bytes']) && diff --git a/js/test/.eslintrc.cjs b/js/test/.eslintrc.cjs index bb388f463af..41197c6edb8 100644 --- a/js/test/.eslintrc.cjs +++ b/js/test/.eslintrc.cjs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +/** @type {import('eslint').Linter.Config} */ module.exports = { rules: { "@typescript-eslint/no-require-imports": "off", diff --git a/js/test/unit/ipc/helpers.ts b/js/test/unit/ipc/helpers.ts index 2a228aa7abf..02f45b57428 100644 --- a/js/test/unit/ipc/helpers.ts +++ b/js/test/unit/ipc/helpers.ts @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -import * as fs from 'fs'; +import * as fs from 'node:fs'; import { fs as memfs } from 'memfs'; -import { PassThrough, Readable } from 'stream'; +import { PassThrough, Readable } from 'node:stream'; import { RecordBatchFileWriter, diff --git a/js/test/unit/ipc/reader/streams-node-tests.ts b/js/test/unit/ipc/reader/streams-node-tests.ts index 2e3f08c4e78..bde685cb952 100644 --- a/js/test/unit/ipc/reader/streams-node-tests.ts +++ b/js/test/unit/ipc/reader/streams-node-tests.ts @@ -101,7 +101,7 @@ import { it('readAll() should pipe to separate NodeJS WritableStreams', async () => { const { default: MultiStream } = await import('multistream'); - const { PassThrough } = await import('stream'); + const { PassThrough } = await import('node:stream'); expect.hasAssertions();