eslint-plugin-testing-library icon indicating copy to clipboard operation
eslint-plugin-testing-library copied to clipboard

Prepare the rules for ESLint v9

Open Belco90 opened this issue 1 year ago • 6 comments

Plugin version

n/a

What problem do you want to solve?

Your take on the correct solution?

Apply the changes mentioned in the linked migration docs so the custom rules are adapted to ESLint v9 and the

Anything else?

No response

Do you want to submit a pull request to implement this change?

Yes

Belco90 avatar Apr 16 '24 13:04 Belco90

An example of a similar migration on another eslint plugin: https://github.com/eslint-community/eslint-plugin-security/pull/145/files

thenbe avatar May 07 '24 22:05 thenbe

@thenbe Thanks for the example! It will definitely help when migrating this plugin.

Belco90 avatar May 13 '24 12:05 Belco90

For anyone tracking this PR: eslint released some compatibility utilities that allows users to use this plugin in its current state with eslint v9.

tldr:

// eslint.config.js
import testingLibrary from 'eslint-plugin-testing-library';
+ import { fixupPluginRules } from '@eslint/compat';

	{
		files: ['**/*.test.{js,ts,jsx,tsx}'],
		plugins: {
-			'testing-library': {
-				rules: testingLibrary.rules,
-			},
+			'testing-library': fixupPluginRules({
+				rules: testingLibrary.rules,
+			}),
		},
		rules: testingLibrary.configs.react.rules,
	}

thenbe avatar May 20 '24 21:05 thenbe

For anyone tracking this PR: eslint released some compatibility utilities that allows users to use this plugin in its current state with eslint v9.

Thank you for this. I didn't remember this existed when I went through the flat-config docs.

For anyone using with eslint-plugin-import, when I add the compat lib, I receive an eslint error above the import statement:

// Parse errors in imported module '@eslint/compat': parserPath or languageOptions.parser is required! (undefined:undefined)  import/namespace
import { fixupPluginRules } from "@eslint/compat";

It's important to note that eslint-plugin-import is (also) not quite ready for flat-config, however, I tested a few rules from eslint-plugin-testing-library and the solution offered by @thenbe is working properly based on my limited testing.

jagretz avatar May 24 '24 14:05 jagretz

is there Any ETA for it?

SalahAdDin avatar Aug 13 '24 21:08 SalahAdDin

I have opened #925 which should resolve this without requiring a new major

G-Rath avatar Aug 15 '24 21:08 G-Rath