Open jpoehnelt opened 2 years ago
I use TSESLint, https://www.npmjs.com/package/@typescript-eslint/experimental-utils, for my custom rules which adds TypeScript support to the RuleTester. It would be nice if this was supported more cleanly.
My workaround is below.
import { ESLintUtils, TSESLint } from "@typescript-eslint/experimental-utils"; import { RuleTester as DocRuleTester } from "eslint-docgen"; export class RuleTester extends DocRuleTester implements TSESLint.RuleTester { constructor(options: TSESLint.RuleTesterConfig) { super(options); } public run<TMessageIds extends string, TOptions extends readonly unknown[]>( ruleName: string, rule: TSESLint.RuleModule<TMessageIds, TOptions, TSESLint.RuleListener>, tests: TSESLint.RunTests<TMessageIds, TOptions> ): void { return super.run.call(this, ruleName, rule, tests); } public defineRule< TMessageIds extends string, TOptions extends readonly unknown[] >( name: string, rule: | TSESLint.RuleModule<TMessageIds, TOptions, TSESLint.RuleListener> | TSESLint.RuleCreateFunction< TMessageIds, TOptions, TSESLint.RuleListener > ): void { super.defineRule.call(this, name, rule); } }```
Probably need to extend/fix the TSESLint.RuleTesterConfig to match the JSON schema too.
TSESLint.RuleTesterConfig
I use TSESLint, https://www.npmjs.com/package/@typescript-eslint/experimental-utils, for my custom rules which adds TypeScript support to the RuleTester. It would be nice if this was supported more cleanly.
My workaround is below.