-
Notifications
You must be signed in to change notification settings - Fork 5
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
Replace no-ternary check with no-nested-ternary #62
Conversation
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.
Not usually, no. https://handbook.codeclimate.net/engineering/style_guide/#style-guide-prs I'm against this change, personally. I still think ternarys are too easily/frequently abused and should be avoided since they tend to make for difficult to read code. Making that an enforced part of the style guide is easier overall than getting into nit-picky discussions about whether a particular ternary expression is acceptable. When cases come up where there is a good reason to break a style guide rule, that can always be done by simply ignoring the CC issue (or marking it with an appropriate status) and getting a human approval on the PR, but I do think the default should continue to be to avoid them. |
IMO, If we ignore issues way too frequently it is a sign that the rule should be changed. I think when it comes to view, ternaries makes sense, one example is that |
FWIW @filipesperandio you can also mark specific lines in the source as ignored overall or for certain checks with comments: https://eslint.org/docs/user-guide/command-line-interface#inline-configuration-comments e.g. put |
I'm also favoring this in a way because of how React actually recommends ternaries for certain cases: https://reactjs.org/docs/conditional-rendering.html#inline-if-else-with-conditional-operator |
@eutopian That's what I was trying to refer to 👍 Also thinking more about this no-ternary rule and wondering if that might actually be a clue to extract the expression into a function and then use proper if/else there... maybe it is even better this way.
@wfleming That I feel awful about, I think having the rule in, don't violate it. |
Special in the view, it seems to make sense to have simple ternaries, while
we still don't want for complex ternaries to show up.