Skip to content

Commit 1f4369a

Browse files
Trotttargos
authored andcommitted
tools: enable ESLint require-yield rule
PR-URL: #41463 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]>
1 parent 8090ce7 commit 1f4369a

6 files changed

+21
-20
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ module.exports = {
320320
'quotes': ['error', 'single', { avoidEscape: true }],
321321
'quote-props': ['error', 'consistent'],
322322
'rest-spread-spacing': 'error',
323+
'require-yield': 'error',
323324
'semi': 'error',
324325
'semi-spacing': 'error',
325326
'space-before-blocks': ['error', 'always'],

test/parallel/test-readable-from.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function toReadableOnDataNonObject() {
126126
}
127127

128128
async function destroysTheStreamWhenThrowing() {
129-
async function* generate() {
129+
async function* generate() { // eslint-disable-line require-yield
130130
throw new Error('kaboom');
131131
}
132132

test/parallel/test-stream-compose.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const assert = require('assert');
234234
callback(null, chunk);
235235
})
236236
}),
237-
async function*(source) {
237+
async function*(source) { // eslint-disable-line require-yield
238238
let tmp = '';
239239
for await (const chunk of source) {
240240
tmp += chunk;

test/parallel/test-stream-duplex-from.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream');
134134
}
135135
yield rest;
136136
}),
137-
async function * (source) {
137+
async function * (source) { // eslint-disable-line require-yield
138138
let ret = '';
139139
for await (const x of source) {
140140
ret += x;

test/parallel/test-stream-pipeline.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ const tsp = require('timers/promises');
699699
const ret = pipeline(async function*() {
700700
await Promise.resolve();
701701
yield 'hello';
702-
}, async function*(source) {
703-
for await (const chunk of source) {}
702+
}, async function*(source) { // eslint-disable-line require-yield
703+
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
704704
}, common.mustCall((err) => {
705705
assert.strictEqual(err, undefined);
706706
}));
@@ -712,11 +712,11 @@ const tsp = require('timers/promises');
712712
// AsyncFunction destination is not returned and error is
713713
// propagated.
714714

715-
const ret = pipeline(async function*() {
715+
const ret = pipeline(async function*() { // eslint-disable-line require-yield
716716
await Promise.resolve();
717717
throw new Error('kaboom');
718-
}, async function*(source) {
719-
for await (const chunk of source) {}
718+
}, async function*(source) { // eslint-disable-line require-yield
719+
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
720720
}, common.mustCall((err) => {
721721
assert.strictEqual(err.message, 'kaboom');
722722
}));
@@ -726,7 +726,7 @@ const tsp = require('timers/promises');
726726

727727
{
728728
const s = new PassThrough();
729-
pipeline(async function*() {
729+
pipeline(async function*() { // eslint-disable-line require-yield
730730
throw new Error('kaboom');
731731
}, s, common.mustCall((err) => {
732732
assert.strictEqual(err.message, 'kaboom');
@@ -736,7 +736,7 @@ const tsp = require('timers/promises');
736736

737737
{
738738
const s = new PassThrough();
739-
pipeline(async function*() {
739+
pipeline(async function*() { // eslint-disable-line require-yield
740740
throw new Error('kaboom');
741741
}(), s, common.mustCall((err) => {
742742
assert.strictEqual(err.message, 'kaboom');
@@ -746,7 +746,7 @@ const tsp = require('timers/promises');
746746

747747
{
748748
const s = new PassThrough();
749-
pipeline(function*() {
749+
pipeline(function*() { // eslint-disable-line require-yield
750750
throw new Error('kaboom');
751751
}, s, common.mustCall((err, val) => {
752752
assert.strictEqual(err.message, 'kaboom');
@@ -756,7 +756,7 @@ const tsp = require('timers/promises');
756756

757757
{
758758
const s = new PassThrough();
759-
pipeline(function*() {
759+
pipeline(function*() { // eslint-disable-line require-yield
760760
throw new Error('kaboom');
761761
}(), s, common.mustCall((err, val) => {
762762
assert.strictEqual(err.message, 'kaboom');
@@ -771,7 +771,7 @@ const tsp = require('timers/promises');
771771
yield 'hello';
772772
yield 'world';
773773
}, s, async function(source) {
774-
for await (const chunk of source) {
774+
for await (const chunk of source) { // eslint-disable-line no-unused-vars
775775
throw new Error('kaboom');
776776
}
777777
}, common.mustCall((err, val) => {
@@ -784,8 +784,8 @@ const tsp = require('timers/promises');
784784
const s = new PassThrough();
785785
const ret = pipeline(function() {
786786
return ['hello', 'world'];
787-
}, s, async function*(source) {
788-
for await (const chunk of source) {
787+
}, s, async function*(source) { // eslint-disable-line require-yield
788+
for await (const chunk of source) { // eslint-disable-line no-unused-vars
789789
throw new Error('kaboom');
790790
}
791791
}, common.mustCall((err) => {
@@ -1054,12 +1054,11 @@ const tsp = require('timers/promises');
10541054
const ws = new Writable({
10551055
write: common.mustNotCall()
10561056
});
1057-
pipeline(rs, async function*(stream) {
1058-
/* eslint no-unused-vars: off */
1059-
for await (const chunk of stream) {
1057+
pipeline(rs, async function*(stream) { // eslint-disable-line require-yield
1058+
for await (const chunk of stream) { // eslint-disable-line no-unused-vars
10601059
throw new Error('kaboom');
10611060
}
1062-
}, async function *(source) {
1061+
}, async function *(source) { // eslint-disable-line require-yield
10631062
for await (const chunk of source) {
10641063
res += chunk;
10651064
}
@@ -1394,7 +1393,7 @@ const tsp = require('timers/promises');
13941393
const ac = new AbortController();
13951394
const signal = ac.signal;
13961395
pipelinep(
1397-
async function * ({ signal }) {
1396+
async function * ({ signal }) { // eslint-disable-line require-yield
13981397
await tsp.setTimeout(1e6, signal);
13991398
},
14001399
async function(source) {

test/parallel/test-worker-message-port-terminate-transfer-list.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if (!process.env.HAS_STARTED_WORKER) {
1818

1919
// Make sure we don’t end up running JS after the infinite loop is broken.
2020
port1.postMessage({}, {
21+
// eslint-disable-next-line require-yield
2122
transfer: (function*() { while (true); })()
2223
});
2324

0 commit comments

Comments
 (0)