diff --git a/.eslintrc.yml b/.eslintrc.yml index a9c53a97d4..d0b1d03b15 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -298,7 +298,7 @@ rules: capitalized-comments: off # maybe consistent-this: off func-name-matching: off - func-names: off + func-names: [error, as-needed] # improve debug experience func-style: off id-denylist: off id-length: off diff --git a/resources/eslint-internal-rules/no-dir-import.js b/resources/eslint-internal-rules/no-dir-import.js index 156a4e9741..5322039875 100644 --- a/resources/eslint-internal-rules/no-dir-import.js +++ b/resources/eslint-internal-rules/no-dir-import.js @@ -3,7 +3,7 @@ const fs = require('fs'); const path = require('path'); -module.exports = function (context) { +module.exports = function noDirImportRule(context) { return { ImportDeclaration: checkImportPath, ExportNamedDeclaration: checkImportPath, diff --git a/src/jsutils/__tests__/inspect-test.js b/src/jsutils/__tests__/inspect-test.js index c600d2e435..7c3197e581 100644 --- a/src/jsutils/__tests__/inspect-test.js +++ b/src/jsutils/__tests__/inspect-test.js @@ -168,6 +168,7 @@ describe('inspect', () => { (Foo.prototype: any)[Symbol.toStringTag] = 'Bar'; expect(inspect([[new Foo()]])).to.equal('[[[Bar]]]'); + // eslint-disable-next-line func-names const objectWithoutClassName = new (function () { // eslint-disable-next-line no-invalid-this this.foo = 1; diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index e1feb4b19c..446db6b564 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -897,12 +897,14 @@ describe('Subscription Publish Phase', () => { }); it('should handle error during execution of source event', async () => { + async function* generateEmails() { + yield { email: { subject: 'Hello' } }; + yield { email: { subject: 'Goodbye' } }; + yield { email: { subject: 'Bonjour' } }; + } + const erroringEmailSchema = emailSchemaWithResolvers( - async function* () { - yield { email: { subject: 'Hello' } }; - yield { email: { subject: 'Goodbye' } }; - yield { email: { subject: 'Bonjour' } }; - }, + generateEmails, (event) => { if (event.email.subject === 'Goodbye') { throw new Error('Never leave.'); @@ -975,11 +977,13 @@ describe('Subscription Publish Phase', () => { }); it('should pass through error thrown in source event stream', async () => { + async function* generateEmails() { + yield { email: { subject: 'Hello' } }; + throw new Error('test error'); + } + const erroringEmailSchema = emailSchemaWithResolvers( - async function* () { - yield { email: { subject: 'Hello' } }; - throw new Error('test error'); - }, + generateEmails, (email) => email, ); @@ -1029,11 +1033,13 @@ describe('Subscription Publish Phase', () => { }); it('should resolve GraphQL error from source event stream', async () => { + async function* generateEmails() { + yield { email: { subject: 'Hello' } }; + throw new GraphQLError('test error'); + } + const erroringEmailSchema = emailSchemaWithResolvers( - async function* () { - yield { email: { subject: 'Hello' } }; - throw new GraphQLError('test error'); - }, + generateEmails, (email) => email, );