-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): add strict-comparisons rule #314
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(eslint-plugin): add strict-comparisons rule #314
Conversation
Codecov Report
@@ Coverage Diff @@
## master #314 +/- ##
=========================================
- Coverage 97.2% 97.11% -0.1%
=========================================
Files 68 69 +1
Lines 2505 2562 +57
Branches 387 393 +6
=========================================
+ Hits 2435 2488 +53
- Misses 44 46 +2
- Partials 26 28 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't give much of an in-depth review of the type code right now.
but test coverage and documentation looks good.
So I think from my side this would be ready. Is there anything else I should do? @bradzacher @mohsen1 The corresponding tslint PR is still pending due to some compatibility issues with TS 2.1 and some new linting errors in their codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few nits, otherwise LGTM.
It would be good to see some examples/docs clarifying what cases are valid with some more types.
i.e. it's not obvious from the docs (or tests) whether I can do this without the allowObjectEqualComparison
option, because your examples mostly use literals:
const x : T | null = ...;
if (x === null) { .... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work!
@bradzacher thanks. I'll update the docs and examples to clarify the different cases, once that is done I think it's ready from my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the docs and fix the merge conflict and this LGTM
Hi @AndreasGassmann, thanks again for the PR, when do you think you will have chance to finalise this one? |
Sorry for not working on this for so long. I'll look at it this week. |
Adds a
strict-comparisons
rule.I also made a PR on the TSLint repo palantir/tslint#4519 which addresses an open issue palantir/tslint#3574. Once that one gets merged, I'll update the references in this PR.
I'm not sure about the name, I started calling it
no-object-comparisons
, but now it feels like it's doing more than just that, sostrict-comparisons
seems more fitting.I'll have to migrate over some more tests from the TSLint repo, but because of the different format this takes quite some time.