testing-library / eslint-plugin-testing-library

ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library
https://npm.im/eslint-plugin-testing-library
MIT License
982 stars 137 forks source link

Prepare the plugin for flat config #853

Closed Belco90 closed 1 month ago

Belco90 commented 9 months ago

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 plugin is compatible with flat config mechanism

Anything else?

No response

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

Yes

Belco90 commented 5 months ago

Adding backwards compatibility is a bit painful, so I'll implement the ESLint v9 compatibility changes as part of the next major version of the plugin.

studioswong commented 5 months ago

Hello, @Belco90, thank you for setting this up as I can envision this being a pressing issue as more and more of us start to look into migrating to ESLint v9 and changing to use flat config.

While the related changes for compatibility for ESLint v9 are being implemented, are there any way for us to specify using the eslint-plugin-testing-library as a plugin in flat config ?( I am still on ESLint v8.57 so technically should still be able to use the testing library plugin, just that we have migrated to use flat config in preparation for the migration)

I have tried the typical way of importing the library and specifying it as a plugin under plugins, as per recommendations for the migration guide, but unfortunately it doesn't work. Not sure if there is a specific way that I should specify the plugin? ( such as specifying it diirectly in the config array like how we usually use for extends in the old config setup?)

Thank you!

Belco90 commented 5 months ago

Hey @studioswong! I don't think there is a way to make the plugin compatible with ESLint v9 until we released the corresponding changes, so I'm afraid you'll have to wait until the next version of the plugin.

I'm working on it already, you can follow the progress here: https://github.com/orgs/testing-library/projects/19

edit:

To make it clear, you can use the plugin with ESLint v9 if not using the new flat config. Otherwise, this ticket must be addressed for flat config compatibility.

studioswong commented 5 months ago

Thank you so much for your speedy reply @Belco90 ! Gotcha - So basically it's all down to flat config and not ESLint v9 😄

Really looking forward to your work with the support for flat configs - I'm sure a lot of users will come across this soon in the coming weeks! and thanks so much for the great work with this plugin!

Belco90 commented 5 months ago

Adding backwards compatibility is a bit painful, so I'll implement the ESLint v9 compatibility changes as part of the next major version of the plugin.

Finally keeping backwards compatibility with RC config, but those configs will be renamed with a -legacy suffix so this will be a breaking change anyway.

raypatterson commented 4 months ago

you can use the plugin with ESLint v9

If this is true, can we update the peer dependencies to include ESLint 9?

thiagoboa commented 3 months ago

thenbe shared in this other issue a working example on how to use this plugin with flat config using ESLint compatibility utilities, and it works like a charm: https://github.com/testing-library/eslint-plugin-testing-library/issues/899#issuecomment-2121272355

G-Rath commented 1 month ago

I've opened #923 which adds backwards compatible support for flat config, based on the prior work I've done on eslint-plugin-jest and other plugins in the ecosystem

github-actions[bot] commented 1 month ago

:tada: This issue has been resolved in version 6.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: