Skip to content

Commit bf31d3c

Browse files
committed
tools: enable no-unused-expressions lint rule
Fixes: #36246 PR-URL: #36248 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0869b82 commit bf31d3c

File tree

51 files changed

+90
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+90
-92
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ module.exports = {
234234
'no-unreachable': 'error',
235235
'no-unsafe-finally': 'error',
236236
'no-unsafe-negation': 'error',
237+
'no-unused-expressions': ['error', { allowShortCircuit: true }],
237238
'no-unused-labels': 'error',
238239
'no-unused-vars': ['error', { args: 'none', caughtErrors: 'all' }],
239240
'no-use-before-define': ['error', {

benchmark/_benchmark_progress.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class BenchmarkProgress {
3939
this.completedConfig = 0;
4040
// Total number of configurations for the current file
4141
this.scheduledConfig = 0;
42-
this.interval; // Updates the elapsed time.
4342
}
4443

4544
startQueue(index) {

benchmark/es/destructuring-bench.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function runSwapManual(n) {
1212
let x, y, r;
1313
bench.start();
1414
for (let i = 0; i < n; i++) {
15-
x = 1, y = 2;
15+
x = 1;
16+
y = 2;
1617
r = x;
1718
x = y;
1819
y = r;
@@ -26,7 +27,8 @@ function runSwapDestructured(n) {
2627
let x, y;
2728
bench.start();
2829
for (let i = 0; i < n; i++) {
29-
x = 1, y = 2;
30+
x = 1;
31+
y = 2;
3032
[x, y] = [y, x];
3133
assert.strictEqual(x, 2);
3234
assert.strictEqual(y, 1);

benchmark/perf_hooks/bench-eventlooputil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function main({ method, n }) {
3333
function benchIdleTime(n) {
3434
bench.start();
3535
for (let i = 0; i < n; i++)
36-
nodeTiming.idleTime;
36+
nodeTiming.idleTime; // eslint-disable-line no-unused-expressions
3737
bench.end(n);
3838
}
3939

benchmark/process/bench-env.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function main({ n, operation }) {
1313
case 'get':
1414
bench.start();
1515
for (let i = 0; i < n; i++) {
16-
process.env.PATH;
16+
process.env.PATH; // eslint-disable-line no-unused-expressions
1717
}
1818
bench.end(n);
1919
break;
@@ -42,7 +42,7 @@ function main({ n, operation }) {
4242
case 'query':
4343
bench.start();
4444
for (let i = 0; i < n; i++) {
45-
'PATH' in process.env;
45+
'PATH' in process.env; // eslint-disable-line no-unused-expressions
4646
}
4747
bench.end(n);
4848
break;

benchmark/string_decoder/string-decoder-create.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const bench = common.createBenchmark(main, {
1212
function main({ encoding, n }) {
1313
bench.start();
1414
for (let i = 0; i < n; ++i) {
15-
const sd = new StringDecoder(encoding);
16-
!!sd.encoding;
15+
new StringDecoder(encoding);
1716
}
1817
bench.end(n);
1918
}

doc/.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rules:
44
# ease some restrictions in doc examples
55
no-restricted-properties: off
66
no-undef: off
7+
no-unused-expressions: off
78
no-unused-vars: off
89
symbol-description: off
910

lib/internal/assert/assertion_error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class AssertionError extends Error {
455455
}
456456
ErrorCaptureStackTrace(this, stackStartFn || stackStartFunction);
457457
// Create error message including the error code in the name.
458-
this.stack;
458+
this.stack; // eslint-disable-line no-unused-expressions
459459
// Reset the name.
460460
this.name = 'AssertionError';
461461
}

lib/internal/buffer.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -952,18 +952,18 @@ function writeFloatBackwards(val, offset = 0) {
952952
class FastBuffer extends Uint8Array {}
953953

954954
function addBufferPrototypeMethods(proto) {
955-
proto.readBigUInt64LE = readBigUInt64LE,
956-
proto.readBigUInt64BE = readBigUInt64BE,
957-
proto.readBigUint64LE = readBigUInt64LE,
958-
proto.readBigUint64BE = readBigUInt64BE,
959-
proto.readBigInt64LE = readBigInt64LE,
960-
proto.readBigInt64BE = readBigInt64BE,
961-
proto.writeBigUInt64LE = writeBigUInt64LE,
962-
proto.writeBigUInt64BE = writeBigUInt64BE,
963-
proto.writeBigUint64LE = writeBigUInt64LE,
964-
proto.writeBigUint64BE = writeBigUInt64BE,
965-
proto.writeBigInt64LE = writeBigInt64LE,
966-
proto.writeBigInt64BE = writeBigInt64BE,
955+
proto.readBigUInt64LE = readBigUInt64LE;
956+
proto.readBigUInt64BE = readBigUInt64BE;
957+
proto.readBigUint64LE = readBigUInt64LE;
958+
proto.readBigUint64BE = readBigUInt64BE;
959+
proto.readBigInt64LE = readBigInt64LE;
960+
proto.readBigInt64BE = readBigInt64BE;
961+
proto.writeBigUInt64LE = writeBigUInt64LE;
962+
proto.writeBigUInt64BE = writeBigUInt64BE;
963+
proto.writeBigUint64LE = writeBigUInt64LE;
964+
proto.writeBigUint64BE = writeBigUInt64BE;
965+
proto.writeBigInt64LE = writeBigInt64LE;
966+
proto.writeBigInt64BE = writeBigInt64BE;
967967

968968
proto.readUIntLE = readUIntLE;
969969
proto.readUInt32LE = readUInt32LE;

lib/internal/errors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function addCodeToName(err, name, code) {
332332
err.name = `${name} [${code}]`;
333333
// Access the stack to generate the error message including the error code
334334
// from the name.
335-
err.stack;
335+
err.stack; // eslint-disable-line no-unused-expressions
336336
// Reset the name to the actual name.
337337
if (name === 'SystemError') {
338338
ObjectDefineProperty(err, 'name', {
@@ -1411,11 +1411,11 @@ E('ERR_TLS_CERT_ALTNAME_INVALID', function(reason, host, cert) {
14111411
}, Error);
14121412
E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error);
14131413
E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout', Error);
1414-
E('ERR_TLS_INVALID_CONTEXT', '%s must be a SecureContext', TypeError),
1415-
E('ERR_TLS_INVALID_STATE', 'TLS socket connection must be securely established',
1416-
Error),
1414+
E('ERR_TLS_INVALID_CONTEXT', '%s must be a SecureContext', TypeError);
14171415
E('ERR_TLS_INVALID_PROTOCOL_VERSION',
14181416
'%j is not a valid %s TLS protocol version', TypeError);
1417+
E('ERR_TLS_INVALID_STATE', 'TLS socket connection must be securely established',
1418+
Error);
14191419
E('ERR_TLS_PROTOCOL_VERSION_CONFLICT',
14201420
'TLS protocol version %j conflicts with secureProtocol %j', TypeError);
14211421
E('ERR_TLS_RENEGOTIATION_DISABLED',

0 commit comments

Comments
 (0)