Description
Have you read the Troubleshooting section?
Yes
Plugin version
5.3.3
ESLint version
v8.14.0
Node.js version
v16.15.0
package manager and version
npm v8.9.0
Operating system
macOS v12.3.1
Bug description
If there are several Testing Library imports, no-dom-import
doesn't report @testing-library/dom
imports if they are other than the first occurrence between Testing Library imports.
Steps to reproduce
This should be reported but it's not:
import { render } from '@testing-library/react'
import { screen } from '@testing-library/dom'
// ^ this import is not reported since it's not the first Testing Library import
import { App } from '../App'
it('should render a basic demo', () => {
render(<App />)
expect(screen.getByText('Hello Parcel + React!')).toBeInTheDocument()
})
Error output/screenshots
N/A
ESLint configuration
N/A
Rule(s) affected
no-dom-import
Anything else?
This is related to how we store the imported Testing Library module in the internal helpers. This only allows one Testing Library module, so the first one found it's the chosen one for later checks.
I remember mentioning this in another issue/PR, but I can't remember which one. This is not that simple to fix since we need to store a list of Testing Library modules used rather than a single one, updating all the helpers provided internally too.
After we allow storing several Testing Library modules in our core helpers, we will be able to fix the actual issue reported.
Do you want to submit a pull request to fix this bug?
Yes