mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
tools: enable ESLint require-yield rule
PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This commit is contained in:
parent
9bfe60fc20
commit
592f1845fa
@ -320,6 +320,7 @@ module.exports = {
|
||||
'quotes': ['error', 'single', { avoidEscape: true }],
|
||||
'quote-props': ['error', 'consistent'],
|
||||
'rest-spread-spacing': 'error',
|
||||
'require-yield': 'error',
|
||||
'semi': 'error',
|
||||
'semi-spacing': 'error',
|
||||
'space-before-blocks': ['error', 'always'],
|
||||
|
||||
@ -126,7 +126,7 @@ async function toReadableOnDataNonObject() {
|
||||
}
|
||||
|
||||
async function destroysTheStreamWhenThrowing() {
|
||||
async function* generate() {
|
||||
async function* generate() { // eslint-disable-line require-yield
|
||||
throw new Error('kaboom');
|
||||
}
|
||||
|
||||
|
||||
@ -234,7 +234,7 @@ const assert = require('assert');
|
||||
callback(null, chunk);
|
||||
})
|
||||
}),
|
||||
async function*(source) {
|
||||
async function*(source) { // eslint-disable-line require-yield
|
||||
let tmp = '';
|
||||
for await (const chunk of source) {
|
||||
tmp += chunk;
|
||||
|
||||
@ -134,7 +134,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream');
|
||||
}
|
||||
yield rest;
|
||||
}),
|
||||
async function * (source) {
|
||||
async function * (source) { // eslint-disable-line require-yield
|
||||
let ret = '';
|
||||
for await (const x of source) {
|
||||
ret += x;
|
||||
|
||||
@ -699,8 +699,8 @@ const tsp = require('timers/promises');
|
||||
const ret = pipeline(async function*() {
|
||||
await Promise.resolve();
|
||||
yield 'hello';
|
||||
}, async function*(source) {
|
||||
for await (const chunk of source) {}
|
||||
}, async function*(source) { // eslint-disable-line require-yield
|
||||
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
|
||||
}, common.mustCall((err) => {
|
||||
assert.strictEqual(err, undefined);
|
||||
}));
|
||||
@ -712,11 +712,11 @@ const tsp = require('timers/promises');
|
||||
// AsyncFunction destination is not returned and error is
|
||||
// propagated.
|
||||
|
||||
const ret = pipeline(async function*() {
|
||||
const ret = pipeline(async function*() { // eslint-disable-line require-yield
|
||||
await Promise.resolve();
|
||||
throw new Error('kaboom');
|
||||
}, async function*(source) {
|
||||
for await (const chunk of source) {}
|
||||
}, async function*(source) { // eslint-disable-line require-yield
|
||||
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
|
||||
}, common.mustCall((err) => {
|
||||
assert.strictEqual(err.message, 'kaboom');
|
||||
}));
|
||||
@ -726,7 +726,7 @@ const tsp = require('timers/promises');
|
||||
|
||||
{
|
||||
const s = new PassThrough();
|
||||
pipeline(async function*() {
|
||||
pipeline(async function*() { // eslint-disable-line require-yield
|
||||
throw new Error('kaboom');
|
||||
}, s, common.mustCall((err) => {
|
||||
assert.strictEqual(err.message, 'kaboom');
|
||||
@ -736,7 +736,7 @@ const tsp = require('timers/promises');
|
||||
|
||||
{
|
||||
const s = new PassThrough();
|
||||
pipeline(async function*() {
|
||||
pipeline(async function*() { // eslint-disable-line require-yield
|
||||
throw new Error('kaboom');
|
||||
}(), s, common.mustCall((err) => {
|
||||
assert.strictEqual(err.message, 'kaboom');
|
||||
@ -746,7 +746,7 @@ const tsp = require('timers/promises');
|
||||
|
||||
{
|
||||
const s = new PassThrough();
|
||||
pipeline(function*() {
|
||||
pipeline(function*() { // eslint-disable-line require-yield
|
||||
throw new Error('kaboom');
|
||||
}, s, common.mustCall((err, val) => {
|
||||
assert.strictEqual(err.message, 'kaboom');
|
||||
@ -756,7 +756,7 @@ const tsp = require('timers/promises');
|
||||
|
||||
{
|
||||
const s = new PassThrough();
|
||||
pipeline(function*() {
|
||||
pipeline(function*() { // eslint-disable-line require-yield
|
||||
throw new Error('kaboom');
|
||||
}(), s, common.mustCall((err, val) => {
|
||||
assert.strictEqual(err.message, 'kaboom');
|
||||
@ -771,7 +771,7 @@ const tsp = require('timers/promises');
|
||||
yield 'hello';
|
||||
yield 'world';
|
||||
}, s, async function(source) {
|
||||
for await (const chunk of source) {
|
||||
for await (const chunk of source) { // eslint-disable-line no-unused-vars
|
||||
throw new Error('kaboom');
|
||||
}
|
||||
}, common.mustCall((err, val) => {
|
||||
@ -784,8 +784,8 @@ const tsp = require('timers/promises');
|
||||
const s = new PassThrough();
|
||||
const ret = pipeline(function() {
|
||||
return ['hello', 'world'];
|
||||
}, s, async function*(source) {
|
||||
for await (const chunk of source) {
|
||||
}, s, async function*(source) { // eslint-disable-line require-yield
|
||||
for await (const chunk of source) { // eslint-disable-line no-unused-vars
|
||||
throw new Error('kaboom');
|
||||
}
|
||||
}, common.mustCall((err) => {
|
||||
@ -1054,12 +1054,11 @@ const tsp = require('timers/promises');
|
||||
const ws = new Writable({
|
||||
write: common.mustNotCall()
|
||||
});
|
||||
pipeline(rs, async function*(stream) {
|
||||
/* eslint no-unused-vars: off */
|
||||
for await (const chunk of stream) {
|
||||
pipeline(rs, async function*(stream) { // eslint-disable-line require-yield
|
||||
for await (const chunk of stream) { // eslint-disable-line no-unused-vars
|
||||
throw new Error('kaboom');
|
||||
}
|
||||
}, async function *(source) {
|
||||
}, async function *(source) { // eslint-disable-line require-yield
|
||||
for await (const chunk of source) {
|
||||
res += chunk;
|
||||
}
|
||||
@ -1394,7 +1393,7 @@ const tsp = require('timers/promises');
|
||||
const ac = new AbortController();
|
||||
const signal = ac.signal;
|
||||
pipelinep(
|
||||
async function * ({ signal }) {
|
||||
async function * ({ signal }) { // eslint-disable-line require-yield
|
||||
await tsp.setTimeout(1e6, signal);
|
||||
},
|
||||
async function(source) {
|
||||
|
||||
@ -18,6 +18,7 @@ if (!process.env.HAS_STARTED_WORKER) {
|
||||
|
||||
// Make sure we don’t end up running JS after the infinite loop is broken.
|
||||
port1.postMessage({}, {
|
||||
// eslint-disable-next-line require-yield
|
||||
transfer: (function*() { while (true); })()
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user