Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2022-02-03 08:28:06 +0300
committerNode.js GitHub Bot <github-bot@iojs.org>2022-02-05 15:58:27 +0300
commit776d0b4e62b7112fe4c1a05a3eabe8fe2f53edc9 (patch)
tree62d418e6c3d531fb21efbb9aff2e378aeb3ab60f /benchmark
parent912c297b7adccb26ed3ac7bc88c169474a6062da (diff)
benchmark: enable no-empty ESLint rule
PR-URL: https://github.com/nodejs/node/pull/41831 Refs: https://eslint.org/docs/rules/no-empty Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/.eslintrc.yaml1
-rw-r--r--benchmark/es/foreach-bench.js2
-rw-r--r--benchmark/fs/bench-statSync-failure.js1
-rw-r--r--benchmark/fs/read-stream-throughput.js12
-rw-r--r--benchmark/fs/readfile-partitioned.js12
-rw-r--r--benchmark/fs/readfile-promises.js12
-rw-r--r--benchmark/fs/readfile.js12
-rw-r--r--benchmark/fs/write-stream-throughput.js12
-rw-r--r--benchmark/fs/writefile-promises.js6
-rw-r--r--benchmark/misc/punycode.js4
-rw-r--r--benchmark/net/net-c2s-cork.js2
11 files changed, 62 insertions, 14 deletions
diff --git a/benchmark/.eslintrc.yaml b/benchmark/.eslintrc.yaml
index 6871299adec..d7c59654fbe 100644
--- a/benchmark/.eslintrc.yaml
+++ b/benchmark/.eslintrc.yaml
@@ -5,5 +5,6 @@ env:
es6: true
rules:
+ no-empty: error
no-var: error
prefer-arrow-callback: error
diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js
index 6992a1a5749..86bd8dff4c0 100644
--- a/benchmark/es/foreach-bench.js
+++ b/benchmark/es/foreach-bench.js
@@ -22,7 +22,7 @@ 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
+ // eslint-disable-next-line no-unused-vars, no-empty
for (const item of items) {}
}
bench.end(n);
diff --git a/benchmark/fs/bench-statSync-failure.js b/benchmark/fs/bench-statSync-failure.js
index 82cb24c09f4..dd69259eacd 100644
--- a/benchmark/fs/bench-statSync-failure.js
+++ b/benchmark/fs/bench-statSync-failure.js
@@ -21,6 +21,7 @@ function main({ n, statSyncType }) {
try {
fs.statSync(arg);
} catch {
+ // Continue regardless of error.
}
}
}
diff --git a/benchmark/fs/read-stream-throughput.js b/benchmark/fs/read-stream-throughput.js
index 5984317ff91..d4a0a798409 100644
--- a/benchmark/fs/read-stream-throughput.js
+++ b/benchmark/fs/read-stream-throughput.js
@@ -50,7 +50,11 @@ function main(conf) {
buf.fill('x');
}
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
const ws = fs.createWriteStream(filename);
ws.on('close', runTest.bind(null, filesize, highWaterMark, encoding, n));
ws.on('drain', write);
@@ -81,7 +85,11 @@ function runTest(filesize, highWaterMark, encoding, n) {
});
rs.on('end', () => {
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
// MB/sec
bench.end(bytes / (1024 * 1024));
});
diff --git a/benchmark/fs/readfile-partitioned.js b/benchmark/fs/readfile-partitioned.js
index 51700cfd649..fac331ec38b 100644
--- a/benchmark/fs/readfile-partitioned.js
+++ b/benchmark/fs/readfile-partitioned.js
@@ -23,7 +23,11 @@ const bench = common.createBenchmark(main, {
});
function main({ len, dur, concurrent }) {
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
@@ -38,7 +42,11 @@ function main({ len, dur, concurrent }) {
const totalOps = reads + zips;
benchEnded = true;
bench.end(totalOps);
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
}, dur * 1000);
function read() {
diff --git a/benchmark/fs/readfile-promises.js b/benchmark/fs/readfile-promises.js
index 28633c3f064..5cfa5b4cc02 100644
--- a/benchmark/fs/readfile-promises.js
+++ b/benchmark/fs/readfile-promises.js
@@ -20,7 +20,11 @@ const bench = common.createBenchmark(main, {
});
function main({ len, duration, concurrent }) {
- try { fs.unlinkSync(filename); } catch { }
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
@@ -31,7 +35,11 @@ function main({ len, duration, concurrent }) {
setTimeout(() => {
benchEnded = true;
bench.end(writes);
- try { fs.unlinkSync(filename); } catch { }
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
process.exit(0);
}, duration * 1000);
diff --git a/benchmark/fs/readfile.js b/benchmark/fs/readfile.js
index 3f996e02ede..e27fe08f43c 100644
--- a/benchmark/fs/readfile.js
+++ b/benchmark/fs/readfile.js
@@ -20,7 +20,11 @@ const bench = common.createBenchmark(main, {
});
function main({ len, duration, concurrent }) {
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
@@ -31,7 +35,11 @@ function main({ len, duration, concurrent }) {
setTimeout(() => {
benchEnded = true;
bench.end(reads);
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
process.exit(0);
}, duration * 1000);
diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js
index 44a3bb23b04..88d3bce06d1 100644
--- a/benchmark/fs/write-stream-throughput.js
+++ b/benchmark/fs/write-stream-throughput.js
@@ -36,7 +36,11 @@ function main({ dur, encodingType, size }) {
throw new Error(`invalid encodingType: ${encodingType}`);
}
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
let started = false;
let ended = false;
@@ -48,7 +52,11 @@ function main({ dur, encodingType, size }) {
f.on('finish', () => {
ended = true;
const written = fs.statSync(filename).size / 1024;
- try { fs.unlinkSync(filename); } catch {}
+ try {
+ fs.unlinkSync(filename);
+ } catch {
+ // Continue regardless of error.
+ }
bench.end(written / 1024);
});
diff --git a/benchmark/fs/writefile-promises.js b/benchmark/fs/writefile-promises.js
index 2ba25184ff3..8b3cd528bac 100644
--- a/benchmark/fs/writefile-promises.js
+++ b/benchmark/fs/writefile-promises.js
@@ -46,7 +46,11 @@ function main({ encodingType, duration, concurrent, size }) {
benchEnded = true;
bench.end(writes);
for (let i = 0; i < filesWritten; i++) {
- try { fs.unlinkSync(`${filename}-${i}`); } catch { }
+ try {
+ fs.unlinkSync(`${filename}-${i}`);
+ } catch {
+ // Continue regardless of error.
+ }
}
process.exit(0);
}, duration * 1000);
diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js
index 9c674b5deef..d0ee938ebd3 100644
--- a/benchmark/misc/punycode.js
+++ b/benchmark/misc/punycode.js
@@ -4,7 +4,9 @@ const common = require('../common.js');
let icu;
try {
icu = common.binding('icu');
-} catch {}
+} catch {
+ // Continue regardless of error.
+}
const punycode = require('punycode');
const bench = common.createBenchmark(main, {
diff --git a/benchmark/net/net-c2s-cork.js b/benchmark/net/net-c2s-cork.js
index 1493cae68d0..9a112921853 100644
--- a/benchmark/net/net-c2s-cork.js
+++ b/benchmark/net/net-c2s-cork.js
@@ -55,7 +55,7 @@ function main({ dur, len, type }) {
function send() {
socket.cork();
- while (socket.write(chunk, encoding)) {}
+ while (socket.write(chunk, encoding));
socket.uncork();
}
});