Skip to content

Commit 7e1c9ed

Browse files
Enable 'require-await' ESLint check (#2272)
1 parent 5451d5e commit 7e1c9ed

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

.eslintrc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ rules:
172172
prefer-promise-reject-errors: error
173173
prefer-regex-literals: error
174174
radix: error
175-
require-await: off # TODO
175+
require-await: error
176176
require-unicode-regexp: off
177177
vars-on-top: error
178178
yoda: [error, never, { exceptRange: true }]
@@ -291,7 +291,7 @@ rules:
291291
prefer-rest-params: off # TODO
292292
prefer-spread: error
293293
prefer-template: off
294-
require-yield: off
294+
require-yield: error
295295
sort-imports: off
296296
symbol-description: off
297297

src/subscription/__tests__/mapAsyncIterator-test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// @flow strict
22

3+
// FIXME temporary hack until https://github.com/eslint/eslint/pull/12484 is merged
4+
/* eslint-disable require-await */
5+
36
import { expect } from 'chai';
47
import { describe, it } from 'mocha';
58

@@ -270,12 +273,11 @@ describe('mapAsyncIterator', () => {
270273
});
271274

272275
it('closes source if mapper rejects', async () => {
273-
await testClosesSourceWithMapper(async x => {
274-
if (x > 1) {
275-
throw new Error('Cannot count to ' + x);
276-
}
277-
return x;
278-
});
276+
await testClosesSourceWithMapper(x =>
277+
x > 1
278+
? Promise.reject(new Error('Cannot count to ' + x))
279+
: Promise.resolve(x),
280+
);
279281
});
280282

281283
async function testClosesSourceWithRejectMapper(mapper) {
@@ -313,8 +315,8 @@ describe('mapAsyncIterator', () => {
313315
});
314316

315317
it('closes source if mapper rejects', async () => {
316-
await testClosesSourceWithRejectMapper(async error => {
317-
throw new Error('Cannot count to ' + error.message);
318-
});
318+
await testClosesSourceWithRejectMapper(error =>
319+
Promise.reject(new Error('Cannot count to ' + error.message)),
320+
);
319321
});
320322
});

src/subscription/__tests__/subscribe-test.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// @flow strict
22

3+
// FIXME temporary hack until https://github.com/eslint/eslint/pull/12484 is merged
4+
/* eslint-disable require-await */
5+
36
import EventEmitter from 'events';
47

58
import { expect } from 'chai';
@@ -401,16 +404,14 @@ describe('Subscription Initialization Phase', () => {
401404
await testReportsError(subscriptionThrowingErrorSchema);
402405

403406
// Resolving to an error
404-
const subscriptionResolvingErrorSchema = emailSchemaWithResolvers(
405-
async () => new Error('test error'),
407+
const subscriptionResolvingErrorSchema = emailSchemaWithResolvers(() =>
408+
Promise.resolve(new Error('test error')),
406409
);
407410
await testReportsError(subscriptionResolvingErrorSchema);
408411

409412
// Rejecting with an error
410-
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(
411-
async () => {
412-
throw new Error('test error');
413-
},
413+
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(() =>
414+
Promise.reject(new Error('test error')),
414415
);
415416
await testReportsError(subscriptionRejectingErrorSchema);
416417

@@ -457,10 +458,8 @@ describe('Subscription Initialization Phase', () => {
457458
await testReportsError(subscriptionResolvingErrorSchema);
458459

459460
// Rejecting with an error
460-
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(
461-
async () => {
462-
throw new Error('test error');
463-
},
461+
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(() =>
462+
Promise.reject(new Error('test error')),
464463
);
465464
await testReportsError(subscriptionRejectingErrorSchema);
466465

0 commit comments

Comments
 (0)