Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions benchmark/es/foreach-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ function useFor(n, items, count) {
bench.start();
for (let i = 0; i < n; i++) {
for (let j = 0; j < count; j++) {
// eslint-disable-next-line no-unused-vars
const item = items[j];
const _ = items[j];
}
}
bench.end(n);
Expand All @@ -22,8 +21,8 @@ function useFor(n, items, count) {
function useForOf(n, items) {
bench.start();
for (let i = 0; i < n; i++) {
// eslint-disable-next-line no-unused-vars, no-empty
for (const item of items) {}
// eslint-disable-next-line no-empty
for (const _ of items) {}
}
bench.end(n);
}
Expand All @@ -32,8 +31,7 @@ function useForIn(n, items) {
bench.start();
for (let i = 0; i < n; i++) {
for (const j in items) {
// eslint-disable-next-line no-unused-vars
const item = items[j];
const _ = items[j];
}
}
bench.end(n);
Expand Down
3 changes: 1 addition & 2 deletions benchmark/fs/bench-opendir.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ async function main({ n, dir, mode, bufferSize }) {
for (let i = 0; i < n; i++) {
if (mode === 'async') {
const dir = await fs.promises.opendir(fullPath, { bufferSize });
// eslint-disable-next-line no-unused-vars
for await (const entry of dir)
for await (const _ of dir)
counter++;
} else if (mode === 'callback') {
const dir = await fs.promises.opendir(fullPath, { bufferSize });
Expand Down
1 change: 0 additions & 1 deletion benchmark/readline/readline-iterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ async function main({ n, type }) {

const readlineIterable = type === 'old' ? oldWay.call(iterable) : iterable;

// eslint-disable-next-line no-unused-vars
for await (const _ of readlineIterable) {
lineCount++;
}
Expand Down
1 change: 0 additions & 1 deletion benchmark/streams/iter-throughput-broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ function benchIter(chunk, numConsumers, datasize, n, totalOps) {

// No-op consumer: drain all batches without collecting
async function drain(source) {
// eslint-disable-next-line no-unused-vars
for await (const _ of source) { /* drain */ }
}

Expand Down
1 change: 0 additions & 1 deletion benchmark/test_runner/run-single-test-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ async function runBenchmark({ numberOfTestFiles, isolation }) {
concurrency: false, // We don't want to run tests concurrently
});

// eslint-disable-next-line no-unused-vars
for await (const _ of stream);

return numberOfTestFiles;
Expand Down
9 changes: 8 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,14 @@ export default [
'no-undef': ['error', { typeof: true }],
'no-undef-init': 'error',
'no-unused-expressions': ['error', { allowShortCircuit: true }],
'no-unused-vars': ['error', { args: 'none', caughtErrors: 'all' }],
'no-unused-vars': ['error', {
args: 'none',
caughtErrors: 'all',
varsIgnorePattern: '^_+$',
caughtErrorsIgnorePattern: '^_+$',
destructuredArrayIgnorePattern: '^_+$',
reportUsedIgnorePattern: true,
}],
'no-use-before-define': ['error', {
classes: true,
functions: false,
Expand Down
24 changes: 8 additions & 16 deletions lib/diagnostics_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ class ActiveChannel {
}

runStores(data, fn, thisArg, ...args) {
// eslint-disable-next-line no-unused-vars
using scope = this.withStoreScope(data);
using _ = this.withStoreScope(data);
return ReflectApply(fn, thisArg, args);
}
}
Expand Down Expand Up @@ -406,8 +405,7 @@ class BoundedChannel {

run(context, fn, thisArg, ...args) {
context ??= {};
// eslint-disable-next-line no-unused-vars
using scope = this.withScope(context);
using _ = this.withScope(context);
return ReflectApply(fn, thisArg, args);
}
}
Expand Down Expand Up @@ -535,8 +533,7 @@ class TracingChannel {

const { error } = this;

// eslint-disable-next-line no-unused-vars
using scope = this.#callWindow.withScope(context);
using _ = this.#callWindow.withScope(context);
try {
const result = ReflectApply(fn, thisArg, args);
context.result = result;
Expand Down Expand Up @@ -568,8 +565,7 @@ class TracingChannel {
context.error = err;
error.publish(context);
// Use continuation window for asyncStart/asyncEnd
// eslint-disable-next-line no-unused-vars
using scope = continuationWindow.withScope(context);
using _ = continuationWindow.withScope(context);
// TODO: Is there a way to have asyncEnd _after_ the continuation?
}

Expand All @@ -581,14 +577,12 @@ class TracingChannel {
function onResolve(result) {
context.result = result;
// Use continuation window for asyncStart/asyncEnd
// eslint-disable-next-line no-unused-vars
using scope = continuationWindow.withScope(context);
using _ = continuationWindow.withScope(context);
// TODO: Is there a way to have asyncEnd _after_ the continuation?
return result;
}

// eslint-disable-next-line no-unused-vars
using scope = this.#callWindow.withScope(context);
using _ = this.#callWindow.withScope(context);
try {
const result = ReflectApply(fn, thisArg, args);
// If the return value is not a thenable, return it directly with a warning.
Expand Down Expand Up @@ -637,17 +631,15 @@ class TracingChannel {
}

// Use continuation window for asyncStart/asyncEnd around callback
// eslint-disable-next-line no-unused-vars
using scope = continuationWindow.withScope(context);
using _ = continuationWindow.withScope(context);
return ReflectApply(callback, this, arguments);
}

const callback = ArrayPrototypeAt(args, position);
validateFunction(callback, 'callback');
ArrayPrototypeSplice(args, position, 1, wrappedCallback);

// eslint-disable-next-line no-unused-vars
using scope = this.#callWindow.withScope(context);
using _ = this.#callWindow.withScope(context);
try {
return ReflectApply(fn, thisArg, args);
} catch (err) {
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/streams/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ async function forEach(fn, options) {
await fn(value, options);
return kEmpty;
}
// eslint-disable-next-line no-unused-vars
for await (const unused of map.call(this, forEachFn, options));
for await (const _ of map.call(this, forEachFn, options));
}

function filter(fn, options) {
Expand Down
6 changes: 2 additions & 4 deletions lib/internal/test_runner/mock/mock_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,7 @@ class MockTimers {
}

// Prototype is read-only, and non assignable through Object.defineProperties
// eslint-disable-next-line no-unused-vars -- used to get the prototype out of the object
const { prototype, ...dateProps } = ObjectGetOwnPropertyDescriptors(NativeDateConstructor);
const { prototype: _, ...dateProps } = ObjectGetOwnPropertyDescriptors(NativeDateConstructor);

// Binds all the properties of Date to the MockDate function
ObjectDefineProperties(
Expand Down Expand Up @@ -478,8 +477,7 @@ class MockTimers {
options);

try {
// eslint-disable-next-line no-unused-vars
for await (const event of eventIt) {
for await (const _ of eventIt) {
yield result;
}
} finally {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-blob-file-backed.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ writeFileSync(testfile5, '');
stream = blob.stream();

const read = async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of stream) {}
};

Expand Down Expand Up @@ -98,7 +98,6 @@ writeFileSync(testfile5, '');
const blob = await openAsBlob(testfile3);
const stream = blob.stream();
const read = async () => {
// eslint-disable-next-line no-unused-vars
for await (const _ of stream) {
writeFileSync(testfile3, data + 'abc');
}
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-fs-promises-file-handle-pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ async function testPullAbortSignal() {

await assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars
for await (const _ of readable) {
assert.fail('Should not reach here');
}
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/test-fs-promises-watch-ignore-invalid.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const { watch } = await import('node:fs/promises');
await assert.rejects(
async () => {
const watcher = watch('.', { ignore: 123 });
// eslint-disable-next-line no-unused-vars
for await (const _ of watcher) {
// Will throw before yielding
}
Expand All @@ -23,7 +22,6 @@ await assert.rejects(
await assert.rejects(
async () => {
const watcher = watch('.', { ignore: '' });
// eslint-disable-next-line no-unused-vars
for await (const _ of watcher) {
// Will throw before yielding
}
Expand Down
20 changes: 10 additions & 10 deletions test/parallel/test-fs-promises-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,61 +83,61 @@ for (const testCase of kCases) {

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch(1)) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch(__filename, 1)) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { persistent: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { recursive: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { encoding: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_VALUE' }).then(common.mustCall());

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { signal: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());

assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { maxQueue: 'silly' })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());
assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { overflow: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_VALUE' }).then(common.mustCall());
assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch('', { overflow: 'barf' })) { }
},
{ code: 'ERR_INVALID_ARG_VALUE' }).then(common.mustCall());
Expand All @@ -147,7 +147,7 @@ assert.rejects(
const { signal } = ac;
setImmediate(() => ac.abort());
await assert.rejects(async () => {
// eslint-disable-next-line no-unused-vars, no-empty
// eslint-disable-next-line no-empty
for await (const _ of watch(__filename, { signal })) { }
}, { name: 'AbortError' });
})().then(common.mustCall());
1 change: 0 additions & 1 deletion test/parallel/test-fs-watch-recursive-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ tmpdir.refresh();
const error = new Error();
const watcher = fs.watch(testsubdir, { recursive: true, signal: AbortSignal.abort(error) });
await assert.rejects(async () => {
// eslint-disable-next-line no-unused-vars
for await (const _ of watcher);
}, { code: 'ABORT_ERR', cause: error });
})().then(common.mustCall());
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-path-resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const backslashRE = /\\/g;

const posixyCwd = common.isWindows ?
(() => {
const _ = process.cwd()
const cwd = process.cwd()
.replaceAll(path.sep, path.posix.sep);
return _.slice(_.indexOf(path.posix.sep));
return cwd.slice(cwd.indexOf(path.posix.sep));
})() :
process.cwd();

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-quic-edge-concurrent-close.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ await clientSession.opened;
// Open a stream so the server session has work, then close from both sides.
const stream = clientSession.createBidirectionalStream();
stream.writer.endSync();
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
await stream.closed;

// Client close happens around the same time as server close above.
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-quic-edge-endpoint-destroy-active.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const serverDone = Promise.withResolvers();

const serverEndpoint = await listen(mustCall(async (serverSession) => {
serverSession.onstream = mustCall(async (stream) => {
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
stream.writer.endSync();
await stream.closed;
});
Expand All @@ -35,7 +35,7 @@ await clientSession.opened;
const stream = clientSession.createBidirectionalStream({
body: encoder.encode('hello'),
});
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
await stream.closed;

// Close the endpoint while the server session is still active
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-quic-edge-idempotent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ await clientSession.opened;
// Signal server to close via stream first (before we close).
const stream = clientSession.createBidirectionalStream();
stream.writer.endSync();
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
await stream.closed;

// Double close() on session — both return the same promise.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-quic-flow-control-concurrent-volume.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ for (let i = 0; i < kStreams; i++) {
}

await Promise.all(streams.map(async (stream) => {
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
await stream.closed;
}));

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-quic-flow-control-large-constrained.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const windowCaps = {

stream.setBody(payload);

for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const stream = clientSession.createBidirectionalStream();
stream.onblocked = mustCallAtLeast(1);
stream.setBody(payload);

for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
for await (const _ of stream) { /* drain */ }
await Promise.all([stream.closed, serverDone.promise]);

// Integrity first: bounded buffering is only interesting if no data was lost.
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-quic-h3-stream-destroy-no-resurrect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ for (let i = 0; i < kRequests; i++) {

// Take one batch of the response, then abandon the rest and destroy, so
// DATA frames keep arriving for a stream we no longer track.
// eslint-disable-next-line no-unused-vars
for await (const _ of stream) break;

stream.destroy();
Expand Down
Loading
Loading