-
Notifications
You must be signed in to change notification settings - Fork 49
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
Rule proposal: No deepEqual for primitives values #158
Comments
Sounds good. Using I couldn't think of a better name. Only thing that comes to mind is Could this be auto-fixable? |
that sounds like a really easy fix, just change the name of the method) to Rule name open to bikeshed for those interested :) |
I wanted to add my 2p. with regards of Having said that, it would be nice if Namely. Users have gajillion of unit tests, it's already tedious to visually grep them. Now, if linter could do optimisation switching Like Sindre said, definitely, let's do auto-fixable. And very important, both ways. Detect comparison to "object-type", switch to What do you think about backwards ( |
Your example doesn't use variables though, I think the values would be displayed, though to your point not as nicely as with
👍 |
@issuehunt has funded $60.00 to this issue.
|
@sindresorhus has rewarded $54.00 to @MrHen. See it on IssueHunt
|
Comparing regular expressions with const ext2regexp = require('ext-to-regexp');
const jsx = ext2regexp('js', 'jsx');
t.deepEqual(jsx, /\.(js|jsx)$/); // Pass
t.is(jsx, /\.(js|jsx)$/);
// Fail: Values are deeply equal to each other, but they are not the same |
@Airkro but it's expected, |
@revelt I know, but this rule keep telling me that I should use |
@Airkro Open a new issue about this. I guess we can add support for detecting |
We shouldn't recommend |
#270 sure |
I see a lot of of uses of
t.deepEqual
that compares to a promitive value when a simplet.is(a, b)
ort.true(a === b)
would work.I'm not sure if there is a big perf hit or something, but I think it's better to use a simpler form of assertion whenever possible. I personally like to use
t.is()
ort.true(===)
instead (frankly, most of my assertions now aret.true()
)Invalid
Valid
As for the rule name, I think this only targets deepEqual and notDeepEqual, so I propose
no-simple-deep-equal
or something equivalent (but would love a better name for it).IssueHunt Summary
mrhen has been rewarded.
Backers (Total: $60.00)
Submitted pull Requests
Tips
IssueHunt has been backed by the following sponsors. Become a sponsor
The text was updated successfully, but these errors were encountered: