typescript-eslint / typescript-eslint

:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript

Home Page:https://typescript-eslint.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancement(rule-tester): FlatRuleTester -> RuleTester

JoshuaKGoldberg opened this issue · comments

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

rule-tester

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

Splitting out of #8211 -> #8969: this issue tracks any updates we'll need corresponding to eslint/eslint#17922.

Additional Info

No response

Hi, I have a question about this issue. Is there any current way without the changes that will be made for this issue to test a flat config custom typescript-eslint rule? At the moment when using RuleTester from @typescript-eslint/rule-tester v7.11.0 I get the error:

FAIL  tests/rules/no-discard-result.test.ts [ tests/rules/no-discard-result.test.ts ]
Error: This method cannot be used with flat config. Add your entries directly into the config array.
 ❯ assertEslintrcConfig ../../node_modules/eslint/lib/linter/linter.js:1256:15
 ❯ Linter.defineRule ../../node_modules/eslint/lib/linter/linter.js:2164:9
 ❯ RuleTester.run ../../node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:400:18
 ❯ tests/rules/no-discard-result.test.ts:15:13
     13| 
     14| describe('ESLint plugin result', () => {
     15|  ruleTester.run('no-discard-result', noDiscardResult, {
       |             ^
     16|   valid: [
     17|    {

This is for https://github.com/sapphiredev/utilities/blob/feat/update-to-eslint-v9-flat-config/packages/eslint-plugin-result/tests/rules/no-discard-result.test.ts

Nope! The way they designed the rule tester it is one or the other. Hence there is two rule tester classes. Our fork came from the legacy config version (before flat config existed) so it doesn't support flat config properties.

But regardless - the only difference is a few property names. The functionality is all the same.

Turns out if I update to the v8 rc then my tests work again so I'll just patiently wait for the typescript-eslint team to finish their work. Looking forward to it, keep up the awesome work!