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

test: run against ESLint v9

Open G-Rath opened this issue 1 year ago • 1 comments

This is branched off of #925


Checks

Changes

  • introduces a new "flat compat" rule tester that accepts tests written for legacy config, and automatically converts them to flat config when running against ESLint v9
    • this is a class I have used in eslint-plugin-jest, eslint-plugin-jest-dom, and eslint-plugin-jest-extended with great successful
  • updates tests to pass when using ESLint v9
  • updates CI to run test suite against ESLint v9

Context

Before saying the plugin officially supports ESLint v9, it should be testing against v9 which in turn requires accounting for v9's defaulting to flat config and the improvements that have been made to the rule tester to help plugin authors catch bugs.

Besides flat config in general, the two notable changes to the rule tester that require changes to this test suite are:

  • it's now an error to have output that matches code
  • it's now an error to have duplicate cases

There's only a couple of occurrences of that first one and the fix is to just specify null instead which means "this rule supports autofix, but for this test case it does not do anything".

The second though requires a lot more work especially because of how much mapping this test suite does meaning addressing them in full would have huge changes to the layout so instead for now I've made all the tests unique typically by adding a comment that mentions the testing framework whose loop they're part of - ideally though a number of these tests should be restructured to pull such cases out of the mapping loops, which is something I'm happy to help with via follow-up and parallel PRs.

I have also cherry-picked the straightforward removal of a number of duplicates into #927 which if landed first would help reduce the overall diff of this pull request.

G-Rath avatar Aug 14 '24 20:08 G-Rath

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.33%. Comparing base (93a6ab9) to head (8d487d5). Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #926      +/-   ##
==========================================
+ Coverage   96.23%   96.33%   +0.09%     
==========================================
  Files          44       46       +2     
  Lines        2419     2481      +62     
  Branches     1000     1028      +28     
==========================================
+ Hits         2328     2390      +62     
  Misses         91       91              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 14 '24 21:08 codecov[bot]

:tada: This PR is included in version 6.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Oct 18 '24 07:10 github-actions[bot]