Skip to content

Enable 'require-await' ESLint check #2272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ rules:
prefer-promise-reject-errors: error
prefer-regex-literals: error
radix: error
require-await: off # TODO
require-await: error
require-unicode-regexp: off
vars-on-top: error
yoda: [error, never, { exceptRange: true }]
Expand Down Expand Up @@ -291,7 +291,7 @@ rules:
prefer-rest-params: off # TODO
prefer-spread: error
prefer-template: off
require-yield: off
require-yield: error
sort-imports: off
symbol-description: off

Expand Down
20 changes: 11 additions & 9 deletions src/subscription/__tests__/mapAsyncIterator-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @flow strict

// FIXME temporary hack until https://github.com/eslint/eslint/pull/12484 is merged
/* eslint-disable require-await */

import { expect } from 'chai';
import { describe, it } from 'mocha';

Expand Down Expand Up @@ -270,12 +273,11 @@ describe('mapAsyncIterator', () => {
});

it('closes source if mapper rejects', async () => {
await testClosesSourceWithMapper(async x => {
if (x > 1) {
throw new Error('Cannot count to ' + x);
}
return x;
});
await testClosesSourceWithMapper(x =>
x > 1
? Promise.reject(new Error('Cannot count to ' + x))
: Promise.resolve(x),
);
});

async function testClosesSourceWithRejectMapper(mapper) {
Expand Down Expand Up @@ -313,8 +315,8 @@ describe('mapAsyncIterator', () => {
});

it('closes source if mapper rejects', async () => {
await testClosesSourceWithRejectMapper(async error => {
throw new Error('Cannot count to ' + error.message);
});
await testClosesSourceWithRejectMapper(error =>
Promise.reject(new Error('Cannot count to ' + error.message)),
);
});
});
19 changes: 9 additions & 10 deletions src/subscription/__tests__/subscribe-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @flow strict

// FIXME temporary hack until https://github.com/eslint/eslint/pull/12484 is merged
/* eslint-disable require-await */

import EventEmitter from 'events';

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

// Resolving to an error
const subscriptionResolvingErrorSchema = emailSchemaWithResolvers(
async () => new Error('test error'),
const subscriptionResolvingErrorSchema = emailSchemaWithResolvers(() =>
Promise.resolve(new Error('test error')),
);
await testReportsError(subscriptionResolvingErrorSchema);

// Rejecting with an error
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(
async () => {
throw new Error('test error');
},
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(() =>
Promise.reject(new Error('test error')),
);
await testReportsError(subscriptionRejectingErrorSchema);

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

// Rejecting with an error
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(
async () => {
throw new Error('test error');
},
const subscriptionRejectingErrorSchema = emailSchemaWithResolvers(() =>
Promise.reject(new Error('test error')),
);
await testReportsError(subscriptionRejectingErrorSchema);

Expand Down