Change default value of allowTernary for no-unused-expressions
See original GitHub issueWhat 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:
- Created 5 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top 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 >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
Ah, you’re right, I’m thinking of
no-unused-variables
. I’d appreciate if a maintainer could hide my comments as off-topic.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.