From 4c12e6eeebe456e3d5e8159ed35ca73d9e969697 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 20 Feb 2023 01:58:32 +0100 Subject: [PATCH] fs: add trailing commas in source files PR-URL: https://github.com/nodejs/node/pull/46696 Reviewed-By: Moshe Atlow Reviewed-By: Darshan Sen Reviewed-By: LiviaMedeiros Reviewed-By: James M Snell --- lib/.eslintrc.yaml | 2 ++ lib/fs.js | 18 +++++++++--------- lib/internal/fs/dir.js | 18 +++++++++--------- lib/internal/fs/promises.js | 8 ++++---- lib/internal/fs/read_file_context.js | 2 +- lib/internal/fs/rimraf.js | 2 +- lib/internal/fs/streams.js | 12 ++++++------ lib/internal/fs/utils.js | 20 ++++++++++---------- lib/internal/fs/watchers.js | 18 +++++++++--------- 9 files changed, 51 insertions(+), 49 deletions(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 7154396f7e2952..b823f15d1c6433 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -270,6 +270,7 @@ overrides: - ./cluster.js - ./console.js - ./constants.js + - ./fs.js - ./internal/assert.js - ./internal/child_process/*.js - ./internal/cli_table.js @@ -278,6 +279,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 847c43de7596dc..be462fd820fed3 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'); @@ -75,7 +75,7 @@ const { }, AbortError, uvErrmapGet, - uvException + uvException, } = require('internal/errors'); const { FSReqCallback } = binding; @@ -122,7 +122,7 @@ const { validateRmOptionsSync, validateRmdirOptions, validateStringAfterArrayBufferView, - warnOnNonPortableTemplate + warnOnNonPortableTemplate, } = require('internal/fs/utils'); const { CHAR_FORWARD_SLASH, @@ -978,7 +978,7 @@ function writev(fd, buffers, position, callback) { ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, { __proto__: null, value: ['bytesWritten', 'buffer'], - enumerable: false + enumerable: false, }); /** @@ -2404,7 +2404,7 @@ function watchFile(filename, options, listener) { // behavioral changes to a minimum. interval: 5007, persistent: true, - ...options + ...options, }; validateFunction(listener, 'listener'); @@ -3122,7 +3122,7 @@ module.exports = fs = { }, // For tests - _toUnixTimestamp: toUnixTimestamp + _toUnixTimestamp: toUnixTimestamp, }; defineLazyProperties( @@ -3140,7 +3140,7 @@ ObjectDefineProperties(fs, { __proto__: null, configurable: false, enumerable: true, - value: constants + value: constants, }, promises: { __proto__: null, @@ -3149,6 +3149,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 c61758d3bd3d5e..41c17de95ed3c4 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'); @@ -107,7 +107,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 getDirectoryEntriesPromise = promisify(getDirents); @@ -323,7 +323,7 @@ class FileHandle extends EventEmitterMixin(JSTransferable) { return { data: { handle }, - deserializeInfo: 'internal/fs/promises:FileHandle' + deserializeInfo: 'internal/fs/promises:FileHandle', }; } @@ -715,7 +715,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 d06f963f6cde8a..313d9ab136ebd4 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -31,10 +31,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, @@ -95,13 +95,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 @@ -753,7 +753,7 @@ const defaultRmOptions = { recursive: false, force: false, retryDelay: 100, - maxRetries: 0 + maxRetries: 0, }; const defaultRmdirOptions = { @@ -804,7 +804,7 @@ const validateRmOptions = hideStackFrames((path, options, expectDir, cb) => { message: 'is a directory', path, syscall: 'rm', - errno: EISDIR + errno: EISDIR, })); } return cb(null, options); @@ -829,7 +829,7 @@ const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => { message: 'is a directory', path, syscall: 'rm', - errno: EISDIR + errno: EISDIR, }); } } @@ -946,5 +946,5 @@ module.exports = { validateRmOptionsSync, validateRmdirOptions, validateStringAfterArrayBufferView, - warnOnNonPortableTemplate + warnOnNonPortableTemplate, }; 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();