From fec6096bf5818b41e7ae5e2601c96a36cd8ce946 Mon Sep 17 00:00:00 2001 From: dimitri Date: Sun, 31 Oct 2021 15:07:24 +0100 Subject: [PATCH] fix CI error on ESLint 7 --- packages/plugin/src/testkit.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index 49ba391cf77..cd60e2da74d 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -11,6 +11,7 @@ export type GraphQLESLintRuleListener = { } & Record; export type GraphQLValidTestCase = Omit & { + name: string; options?: Options; parserOptions?: ParserOptions; }; @@ -50,7 +51,26 @@ export class GraphQLRuleTester extends RuleTester { invalid: GraphQLInvalidTestCase[]; } ): void { - super.run(name, rule as Rule.RuleModule, tests); + const ruleTests = Linter.version.startsWith('8') + ? tests + : { + valid: tests.valid.map(test => { + if (typeof test === 'string') { + return test; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { name, ...testCaseOptions } = test; + return testCaseOptions; + }), + invalid: tests.invalid.map(test => { + // ESLint 7 throws an error on CI - Unexpected top-level property "name" + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { name, ...testCaseOptions } = test; + return testCaseOptions; + }), + }; + + super.run(name, rule as Rule.RuleModule, ruleTests); // Skip snapshot testing if `expect` variable is not defined if (typeof expect === 'undefined') {