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

feat: create prefer-comparison-matcher rule #1015

Merged
merged 1 commit into from Jan 15, 2022

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Dec 31, 2021

As documented, I decided to ignore the fact that you can use the comparison operators with strings but not with the jest matchers because I really don't think there's a good & common-enough use case for doing that (maybe aside from checking string sorting?) that makes it worth giving up being able to autofix.

Am open to PRs if someone wanted to have an option like assumeVariablesHoldNumbers that can be set to false to make this rule give suggestions instead of autofix, but for now have left that out.

I've also made this not do anything with the equality operators, as I'm making that into its own rule since that will have to use suggestions and is a little more complicated in terms of there being three possible operators.

Finally, this rule doesn't enforce one specific matcher in regards to not e.g. it doesn't warn that .not.toBeLessThan could be replaced with .toBeGreaterThanOrEqual.

Closes #989

@G-Rath G-Rath force-pushed the create-prefer-to-be-comparison branch from 764fb5c to ae13bfb Compare January 14, 2022 18:56
@G-Rath G-Rath merged commit eb11876 into main Jan 15, 2022
@G-Rath G-Rath deleted the create-prefer-to-be-comparison branch January 15, 2022 20:32
github-actions bot pushed a commit that referenced this pull request Jan 15, 2022
# [25.6.0](v25.5.0...v25.6.0) (2022-01-15)

### Features

* create `prefer-comparison-matcher` rule ([#1015](#1015)) ([eb11876](eb11876))
@github-actions
Copy link

🎉 This PR is included in version 25.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

[new rule] prefer-to-comparison
1 participant