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-tacit: regression on method calls #805

Closed
abrahamguo opened this issue Apr 14, 2024 · 4 comments · Fixed by #808
Closed

prefer-tacit: regression on method calls #805

abrahamguo opened this issue Apr 14, 2024 · 4 comments · Fixed by #808
Labels
Type: Bug Inconsistencies or issues which will cause a problem for users or implementors.

Comments

@abrahamguo
Copy link

Bug Report

Regression introduced in #801:
prefer-tacit reports on [''].filter(str => /a/.test(str)).

Expected behavior

No errors reported, since changing to [''].filter(/a/.test) causes a JavaScript error.

Actual behavior

No reports by prefer-tacit.

@abrahamguo abrahamguo added Status: Triage This issue needs to be triaged. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors. labels Apr 14, 2024
@RebeccaStevens RebeccaStevens removed the Status: Triage This issue needs to be triaged. label Apr 15, 2024
@RebeccaStevens
Copy link
Collaborator

Looks like regex methods require a this reference to the regex itself, and thus without it things go wrong. I imagine this affects more built-in objects than just regex so let me know if you encounter other ones.

@RebeccaStevens
Copy link
Collaborator

Note: if you do want to use the tacit version, you can with help from bind.
e.g.

const regex = /a/;
[''].filter(regex.test.bind(regex));

@RebeccaStevens
Copy link
Collaborator

I added a new option checkMemberExpressions which is false by default. Setting it to true will enable the previous behavior; except now .bind(...)s are included in the suggestion.

github-actions bot pushed a commit that referenced this issue Apr 15, 2024
## [6.5.1](v6.5.0...v6.5.1) (2024-04-15)

### Bug Fixes

* **prefer-tacit:** don't check member functions by default ([#808](#808)) ([4e6c3a9](4e6c3a9)), closes [#805](#805)
@abrahamguo
Copy link
Author

Perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
2 participants