Skip to content
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

prefer-regexp-test should only apply to strings #1759

Open
DamienCassou opened this issue Mar 27, 2022 · 4 comments
Open

prefer-regexp-test should only apply to strings #1759

DamienCassou opened this issue Mar 27, 2022 · 4 comments
Labels

Comments

@DamienCassou
Copy link

The rule prefer-regexp-test triggers an error for:

criteria.match(item)

but criteria isn't a string it is an instance of my own class. I don't want the rule to trigger.

@fisker
Copy link
Collaborator

fisker commented Mar 29, 2022

I don't think we can do anything, we can't know the types.

@DamienCassou
Copy link
Author

Then I guess the rule shouldn't change the code. Maybe just provide suggestions as discussed in #441?

@fisker
Copy link
Collaborator

fisker commented Mar 29, 2022

If we want to disable auto-fix, I'd prefer to add an option {fix: false}, but still auto-fix by default.

@privatenumber
Copy link
Sponsor Contributor

This autofix also broke my code.

I think the autofix should only apply if it can confidently determine that the type is a RegExp (e.g. declared as a const in the same file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants