diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index d26953f24e9958..db98082b52e7fd 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -258,6 +258,7 @@ overrides: - ./cluster.js - ./console.js - ./constants.js + - ./fs.js - ./internal/assert.js - ./internal/child_process/*.js - ./internal/cli_table.js @@ -266,6 +267,7 @@ overrides: - ./internal/events/*.js - ./internal/fixed_queue.js - ./internal/freelist.js + - ./internal/fs/*.js - ./internal/heap_utils.js - ./internal/http.js - ./internal/idna.js diff --git a/lib/fs.js b/lib/fs.js index c34eda38caa562..dbab47174eea56 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -53,7 +53,7 @@ const { W_OK, X_OK, O_WRONLY, - O_SYMLINK + O_SYMLINK, } = constants; const pathModule = require('path'); @@ -73,7 +73,7 @@ const { }, AbortError, uvErrmapGet, - uvException + uvException, } = require('internal/errors'); const { FSReqCallback } = binding; @@ -121,12 +121,12 @@ const { validateRmdirOptions, validateStringAfterArrayBufferView, validatePrimitiveStringAfterArrayBufferView, - warnOnNonPortableTemplate + warnOnNonPortableTemplate, } = require('internal/fs/utils'); const { Dir, opendir, - opendirSync + opendirSync, } = require('internal/fs/dir'); const { CHAR_FORWARD_SLASH, @@ -974,7 +974,7 @@ function writev(fd, buffers, position, callback) { ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, { __proto__: null, value: ['bytesWritten', 'buffer'], - enumerable: false + enumerable: false, }); /** @@ -2396,7 +2396,7 @@ function watchFile(filename, options, listener) { // behavioral changes to a minimum. interval: 5007, persistent: true, - ...options + ...options, }; validateFunction(listener, 'listener'); @@ -3116,7 +3116,7 @@ module.exports = fs = { }, // For tests - _toUnixTimestamp: toUnixTimestamp + _toUnixTimestamp: toUnixTimestamp, }; ObjectDefineProperties(fs, { @@ -3128,7 +3128,7 @@ ObjectDefineProperties(fs, { __proto__: null, configurable: false, enumerable: true, - value: constants + value: constants, }, promises: { __proto__: null, @@ -3137,6 +3137,6 @@ ObjectDefineProperties(fs, { get() { promises ??= require('internal/fs/promises').exports; return promises; - } - } + }, + }, }); diff --git a/lib/internal/fs/dir.js b/lib/internal/fs/dir.js index 2d9dd4fc638f99..c12bb4cfe5fb22 100644 --- a/lib/internal/fs/dir.js +++ b/lib/internal/fs/dir.js @@ -18,8 +18,8 @@ const { codes: { ERR_DIR_CLOSED, ERR_DIR_CONCURRENT_OPERATION, - ERR_MISSING_ARGS - } + ERR_MISSING_ARGS, + }, } = require('internal/errors'); const { FSReqCallback } = binding; @@ -28,11 +28,11 @@ const { getDirent, getOptions, getValidatedPath, - handleErrorFromBinding + handleErrorFromBinding, } = require('internal/fs/utils'); const { validateFunction, - validateUint32 + validateUint32, } = require('internal/validators'); const kDirHandle = Symbol('kDirHandle'); @@ -60,8 +60,8 @@ class Dir { this[kDirOptions] = { bufferSize: 32, ...getOptions(options, { - encoding: 'utf8' - }) + encoding: 'utf8', + }), }; validateUint32(this[kDirOptions].bufferSize, 'options.bufferSize', true); @@ -239,7 +239,7 @@ function opendir(path, options, callback) { path = getValidatedPath(path); options = getOptions(options, { - encoding: 'utf8' + encoding: 'utf8', }); function opendirCallback(error, handle) { @@ -263,7 +263,7 @@ function opendir(path, options, callback) { function opendirSync(path, options) { path = getValidatedPath(path); options = getOptions(options, { - encoding: 'utf8' + encoding: 'utf8', }); const ctx = { path }; @@ -281,5 +281,5 @@ function opendirSync(path, options) { module.exports = { Dir, opendir, - opendirSync + opendirSync, }; diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index e717f1ef422fbf..31f2be4e800d40 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -22,7 +22,7 @@ const { O_SYMLINK, O_WRONLY, S_IFMT, - S_IFREG + S_IFREG, } = constants; const binding = internalBinding('fs'); @@ -105,7 +105,7 @@ const kLocked = Symbol('kLocked'); const { kUsePromises } = binding; const { Interface } = require('internal/readline/interface'); const { - JSTransferable, kDeserialize, kTransfer, kTransferList + JSTransferable, kDeserialize, kTransfer, kTransferList, } = require('internal/worker/js_transferable'); const { @@ -321,7 +321,7 @@ class FileHandle extends EventEmitterMixin(JSTransferable) { return { data: { handle }, - deserializeInfo: 'internal/fs/promises:FileHandle' + deserializeInfo: 'internal/fs/promises:FileHandle', }; } @@ -710,7 +710,7 @@ async function mkdir(path, options) { } const { recursive = false, - mode = 0o777 + mode = 0o777, } = options || kEmptyObject; path = getValidatedPath(path); validateBoolean(recursive, 'options.recursive'); diff --git a/lib/internal/fs/read_file_context.js b/lib/internal/fs/read_file_context.js index 55ad6d767ecf7d..b1a5d6ae03e953 100644 --- a/lib/internal/fs/read_file_context.js +++ b/lib/internal/fs/read_file_context.js @@ -10,7 +10,7 @@ const { constants: { kReadFileBufferLength, kReadFileUnknownBufferLength, - } + }, } = require('internal/fs/utils'); const { Buffer } = require('buffer'); diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js index 84f32dc6bb99db..877f238011cb95 100644 --- a/lib/internal/fs/rimraf.js +++ b/lib/internal/fs/rimraf.js @@ -26,7 +26,7 @@ const { stat, statSync, unlink, - unlinkSync + unlinkSync, } = fs; const { sep } = require('path'); const { setTimeout } = require('timers'); diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index dd027046092f74..f75d0fba917241 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -104,7 +104,7 @@ const FileHandleOperations = (handle) => { PromisePrototypeThen(handle.writev(buffers, pos), (r) => cb(null, r.bytesWritten, r.buffers), (err) => cb(err, 0, buffers)); - } + }, }; }; @@ -221,7 +221,7 @@ ObjectDefineProperty(ReadStream.prototype, 'autoClose', { }, set(val) { this._readableState.autoDestroy = val; - } + }, }); const openReadFs = deprecate(function() { @@ -301,7 +301,7 @@ ReadStream.prototype.close = function(cb) { ObjectDefineProperty(ReadStream.prototype, 'pending', { __proto__: null, get() { return this.fd === null; }, - configurable: true + configurable: true, }); function WriteStream(path, options) { @@ -382,7 +382,7 @@ ObjectDefineProperty(WriteStream.prototype, 'autoClose', { }, set(val) { this._writableState.autoDestroy = val; - } + }, }); const openWriteFs = deprecate(function() { @@ -487,10 +487,10 @@ WriteStream.prototype.destroySoon = WriteStream.prototype.end; ObjectDefineProperty(WriteStream.prototype, 'pending', { __proto__: null, get() { return this.fd === null; }, - configurable: true + configurable: true, }); module.exports = { ReadStream, - WriteStream + WriteStream, }; diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 1a4b56d4178968..6bf588263f11b1 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -32,10 +32,10 @@ const { ERR_INCOMPATIBLE_OPTION_PAIR, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, - ERR_OUT_OF_RANGE + ERR_OUT_OF_RANGE, }, hideStackFrames, - uvException + uvException, } = require('internal/errors'); const { isArrayBufferView, @@ -96,13 +96,13 @@ const { UV_DIRENT_FIFO, UV_DIRENT_SOCKET, UV_DIRENT_CHAR, - UV_DIRENT_BLOCK + UV_DIRENT_BLOCK, }, os: { errno: { - EISDIR - } - } + EISDIR, + }, + }, } = internalBinding('constants'); // The access modes can be any of F_OK, R_OK, W_OK or X_OK. Some might not be @@ -754,7 +754,7 @@ const defaultRmOptions = { recursive: false, force: false, retryDelay: 100, - maxRetries: 0 + maxRetries: 0, }; const defaultRmdirOptions = { @@ -805,7 +805,7 @@ const validateRmOptions = hideStackFrames((path, options, expectDir, cb) => { message: 'is a directory', path, syscall: 'rm', - errno: EISDIR + errno: EISDIR, })); } return cb(null, options); @@ -830,7 +830,7 @@ const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => { message: 'is a directory', path, syscall: 'rm', - errno: EISDIR + errno: EISDIR, }); } } diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index bc4555584ab1f9..ce885c154c81c5 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -21,7 +21,7 @@ const { const { kFsStatsFieldsNumber, - StatWatcher: _StatWatcher + StatWatcher: _StatWatcher, } = internalBinding('fs'); const { FSEvent } = internalBinding('fs_event_wrap'); @@ -30,12 +30,12 @@ const { EventEmitter } = require('events'); const { getStatsFromBinding, - getValidatedPath + getValidatedPath, } = require('internal/fs/utils'); const { defaultTriggerAsyncIdScope, - symbols: { owner_symbol } + symbols: { owner_symbol }, } = require('internal/async_hooks'); const { toNamespacedPath } = require('path'); @@ -122,7 +122,7 @@ StatWatcher.prototype[kFSStatWatcherStart] = function(filename, const error = uvException({ errno: err, syscall: 'watch', - path: filename + path: filename, }); error.filename = filename; throw error; @@ -207,7 +207,7 @@ function FSWatcher() { const error = uvException({ errno: status, syscall: 'watch', - path: filename + path: filename, }); error.filename = filename; this.emit('error', error); @@ -249,7 +249,7 @@ FSWatcher.prototype[kFSWatchStart] = function(filename, syscall: 'watch', path: filename, message: err === UV_ENOSPC ? - 'System limit for number of file watchers reached' : '' + 'System limit for number of file watchers reached' : '', }); error.filename = filename; throw error; @@ -296,7 +296,7 @@ function emitCloseNT(self) { ObjectDefineProperty(FSEvent.prototype, 'owner', { __proto__: null, get() { return this[owner_symbol]; }, - set(v) { return this[owner_symbol] = v; } + set(v) { return this[owner_symbol] = v; }, }); async function* watch(filename, options = kEmptyObject) { @@ -336,7 +336,7 @@ async function* watch(filename, options = kEmptyObject) { const error = uvException({ errno: status, syscall: 'watch', - path: filename + path: filename, }); error.filename = filename; handle.close(); @@ -354,7 +354,7 @@ async function* watch(filename, options = kEmptyObject) { syscall: 'watch', path: filename, message: err === UV_ENOSPC ? - 'System limit for number of file watchers reached' : '' + 'System limit for number of file watchers reached' : '', }); error.filename = filename; handle.close();