question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make `no-cond-assign` work for ternaries too

See original GitHub issue

What 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Mar 21, 2018

@fvictorio looks like https://github.com/eslint/eslint/pull/10109 already attempts to handle it

0reactions
fvictoriocommented, Mar 21, 2018

Do you folks think this could be a good first contribution? I’d like to give it a try.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found