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.

ignore indent when ternary operator are used

See original GitHub issue

what rule to use when I want indent to be working but it comes to ternary operators I would like to switch off, or even better use 2 spaces or none. Exmp:

amount !== undefined && rate !== undefined
? rateAmount(num, rate)
: '0';

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anikethsahacommented, Jul 20, 2020

That would be an enhancement request. indent is a stylistic rule and according to our new policy, no enhancement for stylistic rules are being accepted

1reaction
anikethsahacommented, Jul 20, 2020

What I understood from the description is that you want both of the code snipped

amount !== undefined && rate !== undefined
? rateAmount(num, rate)
: '0';
amount !== undefined && rate !== undefined
  ? rateAmount(num, rate)
  : '0';

to work without any errors right ?

If so, use { "ignoredNodes": ["ConditionalExpression"] } options. in order to ignore all the conditional operators.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Do nothing" using ternary operator - java - Stack Overflow
The ternary operator is usually used to immediately assign a value. String a = bar() ? foo() : null;. For your usecase, you...
Read more >
Ternary operators are the worst..unless you indent them right!
So I ignore both rules for readability and simplicity of code. I don't use ternaries much, but if I want to use them...
Read more >
multiline-ternary - ESLint - Pluggable JavaScript Linter
This rule enforces or disallows newlines between operands of a ternary expression. Note: The location of the operators is not enforced by this...
Read more >
Java static code analysis: The ternary operator should not be ...
While the ternary operator is pleasingly compact, its use can make code more difficult to read. It should therefore be avoided in favor...
Read more >
Making decisions in your code — conditionals - MDN Web Docs
Comparison operators are used to test the conditions inside our conditional statements. We first looked at comparison operators back in our ...
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