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
992 stars 142 forks source link

Export flat config presets by default #961

Closed Belco90 closed 5 days ago

Belco90 commented 6 days ago

In v6 of this plugin, the default configs exported are the eslintrc format ones, having the flat ones prefixed with flat/. For example, for enabling the recommended React preset, you can set it up:

Since flat config is the default format in ESLint v9, we should switch the default exported configs in this rule, so the flat are the default ones, and the eslintrc are prefixed/suffixed. This is recommended by ESLint:

Export both eslintrc and flat configs. The configs key is only validated when a config is used, so you can provide both formats of configs in the configs key. We recommend that you append older format configs with -legacy to make it clear that these configs will not be supported in the future. For example, if your primary config is called recommended and is in flat config format, then you can also have a config named recommended-legacy that is the eslintrc config format.

Based on this, we would expose flat configs with the regular name (removing the current flat/ prefix), then adding a -legacy suffix to the eslintrc format. The previous example for the React preset would look like this:

This will be a breaking change, so it must be added to the migration guide.

Belco90 commented 6 days ago

@MichaelDeBoey @G-Rath I forgot about this one. For me, it's a must before releasing the next major. Thoughts?

G-Rath commented 6 days ago

Personally I don't think it should be considered critical for this major as it's much of a muchness: the presences of the flat in the name isn't going to stop or slow down migration of flat config, and shouldn't add any maintenance burden because either way you're going to be dealing with two sets of configs (arguably, it's slighter better because "flat" is shorter than "legacy" 😅)

The downside is it's one more thing people have to deal with in upgrading to this new major, but the same argument applies there too: it's a very small change to be just removing four letters and a slash, which'll have to be done at some point 🤷

Either way a new major is going to have to happen someday if you want to remove the legacy configs at all

MichaelDeBoey commented 6 days ago

Having read @G-Rath, I agree that it would probably be better to keep it as-is and just remove legacy configs in a next major release (when ESLint v10 is released)

Belco90 commented 5 days ago

Fair enough, let's leave the current config formats and leave the change for a future major.