Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare the rules for ESLint v9 #899

Open
Belco90 opened this issue Apr 16, 2024 · 4 comments
Open

Prepare the rules for ESLint v9 #899

Belco90 opened this issue Apr 16, 2024 · 4 comments
Assignees
Labels
BREAKING CHANGE This change will require a major version bump v7 Next major v7

Comments

@Belco90
Copy link
Member

Belco90 commented Apr 16, 2024

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 Belco90 self-assigned this Apr 16, 2024
@Belco90 Belco90 added BREAKING CHANGE This change will require a major version bump v7 Next major v7 labels Apr 16, 2024
@thenbe
Copy link

thenbe commented May 7, 2024

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

@Belco90
Copy link
Member Author

Belco90 commented May 13, 2024

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

@thenbe
Copy link

thenbe commented May 20, 2024

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,
	}

@jagretz
Copy link

jagretz commented May 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE This change will require a major version bump v7 Next major v7
Projects
Development

No branches or pull requests

3 participants