Skip to content

Commit

Permalink
lib: enforce use of trailing commas
Browse files Browse the repository at this point in the history
PR-URL: #46881
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 11, 2023
1 parent 413493c commit c463f13
Show file tree
Hide file tree
Showing 68 changed files with 367 additions and 295 deletions.
34 changes: 0 additions & 34 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ env:
es6: true

rules:
comma-dangle: [error, {
arrays: always-multiline,
exports: always-multiline,
functions: always-multiline,
imports: always-multiline,
objects: only-multiline,
}]
prefer-object-spread: error
no-buffer-constructor: error
no-mixed-operators:
Expand Down Expand Up @@ -249,30 +242,3 @@ globals:
module: false
internalBinding: false
primordials: false
overrides:
- files:
- ./*/*.js
- ./*.js
- ./internal/child_process/*.js
- ./internal/cluster/*.js
- ./internal/debugger/*.js
- ./internal/events/*.js
- ./internal/fs/*.js
- ./internal/modules/*.js
- ./internal/per_context/*.js
- ./internal/perf/*.js
- ./internal/policy/*.js
- ./internal/process/*.js
- ./internal/readline/*.js
- ./internal/readme.md
- ./internal/repl/*.js
- ./internal/source_map/*.js
- ./internal/streams/*.js
- ./internal/test/*.js
- ./internal/test_runner/**/*.js
- ./internal/tls/*.js
- ./internal/util/parse_args/*.js
- ./internal/watch_mode/*.js
- ./internal/webstreams/*.js
rules:
comma-dangle: [error, always-multiline]
10 changes: 5 additions & 5 deletions lib/internal/assert/assertion_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const kReadableOperator = {
'Expected "actual" not to be reference-equal to "expected":',
notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:',
notIdentical: 'Values have same structure but are not reference-equal:',
notDeepEqualUnequal: 'Expected values not to be loosely deep-equal:'
notDeepEqualUnequal: 'Expected values not to be loosely deep-equal:',
};

// Comparing short primitives should just show === / !== instead of using the
Expand Down Expand Up @@ -331,11 +331,11 @@ class AssertionError extends Error {
stackStartFn,
details,
// Compatibility with older versions.
stackStartFunction
stackStartFunction,
} = options;
let {
actual,
expected
expected,
} = options;

const limit = Error.stackTraceLimit;
Expand Down Expand Up @@ -430,7 +430,7 @@ class AssertionError extends Error {
value: 'AssertionError [ERR_ASSERTION]',
enumerable: false,
writable: true,
configurable: true
configurable: true,
});
this.code = 'ERR_ASSERTION';
if (details) {
Expand Down Expand Up @@ -479,7 +479,7 @@ class AssertionError extends Error {
const result = inspect(this, {
...ctx,
customInspect: false,
depth: 0
depth: 0,
});

// Reset the properties after inspection.
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/assert/calltracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CallTrackerContext {
actual: this.#calls.length,
expected: this.#expected,
operator: this.#name,
stack: this.#stackTrace
stack: this.#stackTrace,
};
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ class CallTracker {
expected,
// eslint-disable-next-line no-restricted-syntax
stackTrace: new Error(),
name: fn.name || 'calls'
name: fn.name || 'calls',
});
const tracked = new Proxy(fn, {
__proto__: null,
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/bootstrap/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ exposeGetterAndSetter(globalThis,
});

const {
TextEncoder, TextDecoder
TextEncoder,
TextDecoder,
} = require('internal/encoding');
// https://encoding.spec.whatwg.org/#textencoder
exposeInterface(globalThis, 'TextEncoder', TextEncoder);
Expand Down Expand Up @@ -100,7 +101,7 @@ function exposeNamespace(target, name, namespaceObject) {
writable: true,
enumerable: false,
configurable: true,
value: namespaceObject
value: namespaceObject,
});
}

Expand Down
6 changes: 3 additions & 3 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ObjectDefineProperty(process, 'moduleLoadList', {
value: moduleLoadList,
configurable: true,
enumerable: true,
writable: false
writable: false,
});


Expand Down Expand Up @@ -182,7 +182,7 @@ let internalBinding;
const loaderId = 'internal/bootstrap/loaders';
const {
builtinIds,
compileFunction
compileFunction,
} = internalBinding('builtins');

const getOwn = (target, property, receiver) => {
Expand Down Expand Up @@ -350,7 +350,7 @@ class BuiltinModule {
const loaderExports = {
internalBinding,
BuiltinModule,
require: requireBuiltin
require: requireBuiltin,
};

function requireBuiltin(id) {
Expand Down
26 changes: 13 additions & 13 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const deprecationHandler = {
setPrototypeOf(target, proto) {
this.maybeWarn();
return ObjectSetPrototypeOf(target, proto);
}
},
};

// process.config is serialized config.gypi
Expand All @@ -172,7 +172,7 @@ ObjectDefineProperty(process, 'config', {
set(value) {
deprecationHandler.maybeWarn();
processConfig = value;
}
},
});

require('internal/worker/js_transferable').setup();
Expand Down Expand Up @@ -231,7 +231,7 @@ internalBinding('async_wrap').setupHooks(nativeHooks);

const {
setupTaskQueue,
queueMicrotask
queueMicrotask,
} = require('internal/process/task_queues');

// Non-standard extensions:
Expand Down Expand Up @@ -272,11 +272,11 @@ ObjectDefineProperty(process, 'allowedNodeEnvironmentFlags', {
value,
configurable: true,
enumerable: true,
writable: true
writable: true,
});
},
enumerable: true,
configurable: true
configurable: true,
});

// process.assert
Expand All @@ -301,22 +301,22 @@ const features = {
// code cache even if the binary is built with embedded code cache.
get cached_builtins() {
return binding.hasCachedBuiltins();
}
},
};

ObjectDefineProperty(process, 'features', {
__proto__: null,
enumerable: true,
writable: false,
configurable: false,
value: features
value: features,
});

{
const {
onGlobalUncaughtException,
setUncaughtExceptionCaptureCallback,
hasUncaughtExceptionCaptureCallback
hasUncaughtExceptionCaptureCallback,
} = require('internal/process/execution');

// For legacy reasons this is still called `_fatalException`, even
Expand Down Expand Up @@ -373,14 +373,14 @@ if (config.hasOpenSSL) {
function setupPrepareStackTrace() {
const {
setEnhanceStackForFatalException,
setPrepareStackTraceCallback
setPrepareStackTraceCallback,
} = internalBinding('errors');
const {
prepareStackTrace,
fatalExceptionStackEnhancers: {
beforeInspector,
afterInspector
}
afterInspector,
},
} = require('internal/errors');
// Tell our PrepareStackTraceCallback passed to the V8 API
// to call prepareStackTrace().
Expand All @@ -399,7 +399,7 @@ function setupProcessObject() {
enumerable: false,
writable: true,
configurable: false,
value: 'process'
value: 'process',
});

// Create global.process as getters so that we have a
Expand All @@ -425,7 +425,7 @@ function setupGlobalProxy() {
value: 'global',
writable: false,
enumerable: false,
configurable: true
configurable: true,
});
globalThis.global = globalThis;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (credentials.implementsPosixCredentials) {
// ---- compare the setups side-by-side -----

const {
codes: { ERR_WORKER_UNSUPPORTED_OPERATION }
codes: { ERR_WORKER_UNSUPPORTED_OPERATION },
} = require('internal/errors');

function wrappedUmask(mask) {
Expand Down
12 changes: 6 additions & 6 deletions lib/internal/bootstrap/switches/does_own_process_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ if (credentials.implementsPosixCredentials) {
const {
parseFileMode,
validateArray,
validateString
validateString,
} = require('internal/validators');

function wrapPosixCredentialSetters(credentials) {
const {
codes: {
ERR_INVALID_ARG_TYPE,
ERR_UNKNOWN_CREDENTIAL
}
ERR_UNKNOWN_CREDENTIAL,
},
} = require('internal/errors');
const {
validateUint32
validateUint32,
} = require('internal/validators');

const {
Expand All @@ -45,7 +45,7 @@ function wrapPosixCredentialSetters(credentials) {
setegid: _setegid,
seteuid: _seteuid,
setgid: _setgid,
setuid: _setuid
setuid: _setuid,
} = credentials;

function initgroups(user, extraGroup) {
Expand Down Expand Up @@ -99,7 +99,7 @@ function wrapPosixCredentialSetters(credentials) {
setegid: wrapIdSetter('Group', _setegid),
seteuid: wrapIdSetter('User', _seteuid),
setgid: wrapIdSetter('Group', _setgid),
setuid: wrapIdSetter('User', _setuid)
setuid: wrapIdSetter('User', _setuid),
};
}

Expand Down
16 changes: 8 additions & 8 deletions lib/internal/bootstrap/switches/is_main_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { ObjectDefineProperty } = primordials;
const rawMethods = internalBinding('process_methods');
const {
addSerializeCallback,
isBuildingSnapshot
isBuildingSnapshot,
} = require('v8').startupSnapshot;
// TODO(joyeecheung): deprecate and remove these underscore methods
process._debugProcess = rawMethods._debugProcess;
Expand All @@ -21,7 +21,7 @@ function defineStream(name, getter) {
__proto__: null,
configurable: true,
enumerable: true,
get: getter
get: getter,
});
}

Expand All @@ -32,7 +32,7 @@ defineStream('stderr', getStderr);
// Worker threads don't receive signals.
const {
startListeningIfSignal,
stopListeningIfSignal
stopListeningIfSignal,
} = require('internal/process/signal');
process.on('newListener', startListeningIfSignal);
process.on('removeListener', stopListeningIfSignal);
Expand Down Expand Up @@ -72,13 +72,13 @@ function createWritableStdioStream(fd) {
stream = new net.Socket({
handle: process[kChannelHandle],
readable: false,
writable: true
writable: true,
});
} else {
stream = new net.Socket({
fd,
readable: false,
writable: true
writable: true,
});
}

Expand All @@ -93,7 +93,7 @@ function createWritableStdioStream(fd) {
stream = new Writable({
write(buf, enc, cb) {
cb();
}
},
});
}
}
Expand Down Expand Up @@ -216,14 +216,14 @@ function getStdin() {
handle: process.channel,
readable: true,
writable: false,
manualStart: true
manualStart: true,
});
} else {
stdin = new net.Socket({
fd: fd,
readable: true,
writable: false,
manualStart: true
manualStart: true,
});
}
// Make sure the stdin can't be `.end()`-ed
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/bootstrap/switches/is_not_main_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function defineStream(name, getter) {
__proto__: null,
configurable: true,
enumerable: true,
get: getter
get: getter,
});
}

Expand All @@ -21,7 +21,7 @@ defineStream('stderr', getStderr);
// Worker threads don't receive signals.
const {
startListeningIfSignal,
stopListeningIfSignal
stopListeningIfSignal,
} = require('internal/process/signal');
process.removeListener('newListener', startListeningIfSignal);
process.removeListener('removeListener', stopListeningIfSignal);
Expand All @@ -30,7 +30,7 @@ process.removeListener('removeListener', stopListeningIfSignal);
// ---- compare the setups side-by-side -----

const {
createWorkerStdio
createWorkerStdio,
} = require('internal/worker/io');

let workerStdio;
Expand Down
Loading

0 comments on commit c463f13

Please sign in to comment.