You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a helper function that used render internally, I was getting an error (testing-library/render-result-naming-convention) telling me I've picked a poor name and that I should incorrectly destructure the results. Oddly, this only seemed to happen if I imported the function, but used within the same file.
Steps to reproduce
// MyComponent.helper.tsximport{render}from'@testing-library/react';importMyComponentfrom'./MyComponent';exportfunctionmakeComponentRenderer(config){// do some stuff...returnfunction(){// do some other stuff...returnrender(<MyComponent/>);}}// When used inside the file, it works without eslint complainingconstconfig={/* ... */};constsomeInternal=makeComponentRenderer(config);// OK// Elsewhere.tsximport{makeComponentRenderer}from'./MyComponent.helper';constconfig={/* ... */};// ESLint: `renderMyComponent ` is not a recommended name for `render` returned value. Instead, you should destructure it, or name it using one of: `view`, or `utils`(testing-library/render-result-naming-convention)constrenderMyComponent=makeComponentRenderer(config);// ERROR
Hi @HenryHall. I'm afraid this is a behaviour related to the Aggressive Reporting feature. In particular, this is coming from custom-renders mechanism.
Please read those docs to know more about how to restrict such behaviour.
Have you read the Troubleshooting section?
Yes
Plugin version
v5.10.0
ESLint version
v8.31.0
Node.js version
v16.8.0
package manager and version
npm 8.19.2
Operating system
Windows 10
Bug description
When creating a helper function that used
render
internally, I was getting an error (testing-library/render-result-naming-convention
) telling me I've picked a poor name and that I should incorrectly destructure the results. Oddly, this only seemed to happen if I imported the function, but used within the same file.Steps to reproduce
Error output/screenshots
No response
ESLint configuration
Rule(s) affected
testing-library/render-result-naming-convention
Anything else?
No response
Do you want to submit a pull request to fix this bug?
No
The text was updated successfully, but these errors were encountered: