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') {