-
Notifications
You must be signed in to change notification settings - Fork 889
Add strict-comparisons Rule #4519
Add strict-comparisons Rule #4519
Conversation
Looks like there are some cases that I didn't think about. Some of the things I saw:
|
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.
Posted a few comments on the rule name and that large conditional.
Love the test cases!
I see a couple of things that are still open:
|
All right, this is in! Thanks so much @AndreasGassmann for getting started on the rule implementation and working earlier this year on the initial rounds of feedback. |
Feedback from a user who likes to use Example code :
Lint error with this rule enabled: To me there seems absolutely nothing wrong with testing a variable of type |
Love it! 💖 Could you please file a new issue for feedback? Separate issues and PRs for different topics are easier to track and search for. |
Absolutely! Searching through the issues my experience seems similar or identical to #4774, so I'll leave it at that. Thanks! |
PR checklist
Overview of change:
This rule disallows the comparison of objects.
>
,>=
,<
,<=
are only allowed if the operands are of type number.===
and!==
are only allowed for operands of typenumber
,string
,boolean
andenum
or if either of the operands isnull
orundefined
.Is there anything you'd like reviewers to focus on?
This is my first tslint rule and in general the first time I took a closer look at the typescript internals.
I'm not sure if all the type checks are bullet proof. I'm pretty sure there's a better way to do those which I haven't figured out yet.
CHANGELOG.md entry:
[new-rule]
strict-comparison