-
Notifications
You must be signed in to change notification settings - Fork 148
V4 plugin runs against code #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Running into the same. Tons of false positives with any method called
|
Just to provide more detail:
There is no information on how to revert to previous behavior when you don't have a custom utility file but just want to use @Belco90 given how aggressive this check is, wouldn't it more reasonable to assume by default that most users won't have the specialized utils? Otherwise you're introducing a ton of unpredictable fragility, since stuff will randomly break on ppl when they happen to introduce a new unrelated call with a name that the plugin finds suspicious. Would you consider reversing the default or providing a simple way to manually opt out of this feature? It's pretty simple to use overrides to only apply the plugin to |
Hey there! Sorry for the issues the Aggressive Reporting is causing. We should have clarified how to run With the default config mentioned on the README the plugin will be run against all your files indeed. We thought about trying to run the rules only against test files, but that's out of the scope of the plugin since 1) each user can potentially have a different setup for their testing files and 2) ESLint already handles this situation. Instead, you should use ESLint overrides to run the rules from this plugin against your test files. Assuming you are using the same pattern for your test files as Jest by default, this config would run // .eslintrc
{
// testing library loaded but not enabled here since this it would be globally applied
extends: ['airbnb', 'plugin:prettier/recommended'],
plugins: ['react-hooks', 'testing-library'],
overrides: [
{
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
// enabled only for matching files
extends: ['plugin:testing-library/react'],
}
]
} I'll create a PR to include this info in the main installation info in the README. Additionally, |
@Belco90 thanks for the quick response, but it feels wrong to use test file names to apply these rules. Application code is very likely to use I left a comment on #222 describing why I think the new default behavior is the wrong choice, but I don't expect you to change the default because of one unhappy user :) I am hoping you will consider adding a way to reverse the behavior via configuration to entirely opt out of aggressive checks & opt in for specific utils. Thank you! |
@9still no problem at all, I understand your frustration and I'm sorry about this. However I have to admit that we opted for this in favor of avoiding false negatives: we preferred to get developers opening issues to figure out how to opt out some Aggressive Reporting since they can spot false positives, rather than having developers without realizing they need to set up something else to get the plugin working correctly. Having said that, that doesn't mean we have put the necessary documentation and config options in place to do so. So apart from clarifying how to make the plugin to be run only on desired test files, we can add extra config to disable the Aggressive Reporting entirely. Aggressive Reporting has 3 mechanisms, and 2 of them can be disabled already: the module from where utils are imported, and the render methods. It's not really clear how to disable them though, so I think it's a good idea to include a new Additionally, for the 3rd mechanism of Aggressive Reporting (the queries), we need to add a new Shared Setting which allows us to 1) customize the list of custom queries to be reported or 2) to switch off this mechanism. I think including these improvements we would cover all different cases. |
I updated the proposal for Let me know what you think @9still @DavidHenri008. I believe with that + previous suggestion around allowing to disable Aggressive Reporting entirely with ease, we would cover everything :) |
v4.0.1 available which would prevent |
* docs: update README with more info around Aggressive Reporting * docs: remove unnecessary module.exports syntax * docs: improve running plugin on testing files * docs: remove wrong option for test files Co-authored-by: Michaël De Boey <[email protected]> * docs: transform bold texts into headings Co-authored-by: Michaël De Boey <[email protected]> Co-authored-by: Michaël De Boey <[email protected]> Closes #331
Thanks @Belco90! The proposals sound great! I won't get to play with 4.0.1 until next week, but look forward to trying it out! |
🎉 This issue has been resolved in version 4.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
v4.1.0 has been released with a new shared setting for restricting Aggressive Queries Reporting + a new |
Thanks again @Belco90 ! Pulled down the new version & it's working great! |
Glad to hear it solves the described limitation. Thanks for your feedback too! |
I upgraded to the latest version, 4.0.0, and I cannot build my code anymore since the plugin finds errors in my code.
With the following configuration :
I am getting the
no-node-access
error for the codedocument.getElementById('root')
:I was expecting the rules to be applied to only .test.js files.
The text was updated successfully, but these errors were encountered: