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.

Change default value of allowTernary for no-unused-expressions

See original GitHub issue

What rule do you want to change? I want to change no-unused-expressions, and set the default value of allowTernary to true. I don’t see how an expression is unused in a ternary expression or at least, I would argue that this uncommon.

Does this change cause the rule to produce more or fewer warnings? This should produce less warnings.

How will the change be implemented? (New option, new default behavior, etc.)? New default behavior

Please provide some example code that this change will affect:

let isThisTrue = funcThatReturnsABoolean();
isThisTrue ? doThis() : doThat();

What does the rule currently do for this code? It will generate an error/warning about no-unused-expressions for isThisTrue.

What will the rule do after it’s changed? It won’t add a warning.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Oct 12, 2018

Ah, you’re right, I’m thinking of no-unused-variables. I’d appreciate if a maintainer could hide my comments as off-topic.

0reactions
HRK44commented, Oct 15, 2018

Thanks for your input. After reading the specs, it seems that the ternary operator should return something - thus triggering the no-unused-expression in my example. I guess this works fine then with the current state. Feel free to re-open if you think this is still worth evaluating.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-expressions - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Nice way to get rid of no-unused-expressions linter error with ...
This allows you to use the default configuration for all other rules while ignoring that rule specifically only on files in that folder....
Read more >
Rule no-unused-expressions - ESLint中文
allowTernary set to true will enable you use ternary operators in your expressions similarly to short circuit evaluations (Default: false ).
Read more >
typescript-eslint/no-unused-expressions' was not found
I want to use Jasmine and i'm in the middle of the tutorial of Jasmine, but they don't mention in the document how...
Read more >
no-unused-expressions in React with conditionals-babel.js
Option 2 - find the rule in your .eslint file, and change to rule to allow ternary expressions: no-unused-expressions: ["error", { "allowTernary": true...
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