Make `no-cond-assign` work for ternaries too
See original GitHub issueWhat rule do you want to change?
no-cond-assign
Does this change cause the rule to produce more or fewer warnings?
More warnings
How will the change be implemented? (New option, new default behavior, etc.)?
I guess new default?
Please provide some example code that this change will affect:
const str = (x = 0) ? 'zero' : 'non-zero'
What does the rule currently do for this code?
No warnings are produced
What will the rule do after it’s changed?
Produce an “Unexpected assignment” warning for the condition of the ternary
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Conditional (ternary) operator - JavaScript - MDN Web Docs
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?)
Read more >Which coding style you use for ternary operator? [closed]
..but usually only if putting it all on one line makes it too long. ... #3 "Non-obvious Ternary Behaviour" explains why the following...
Read more >Using The JavaScript Ternary Operator Effectively
The JavaScript ternary operator is a useful tool that you'll encounter in code quite often. Ternary operators can make statements more conc.
Read more >Make Your Code Cleaner with JavaScript Ternary Operator
This tutorial shows you how to use the JavaScript ternary operator as the shortcut of the if-else statement to make your code cleaner....
Read more >Quick Tip: How to Use the Ternary Operator in JavaScript
It makes the code shorter and more readable. It can be used to assign a value to a variable based on a condition,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fvictorio looks like https://github.com/eslint/eslint/pull/10109 already attempts to handle it
Do you folks think this could be a good first contribution? I’d like to give it a try.