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.

no-unused-expressions rule should allow `foo && foo()`

See original GitHub issue

From the rule docs, This rule aims to eliminate unused expressions. The value of an expression should always be used, except in the case of expressions that side effect: function calls, assignments, and the new operator..

I believe the syntax ``foo && foo()` should be considered valid here as it’s a function call with potential side effects. This syntax allows for quite clean truthfulness checks inside code, and it would be nice if I could use this syntax with the rest of the rules inside no-unused-expressions. (If not, please let me opt out of just this one use-case)

Issue Analytics

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

github_iconTop GitHub Comments

KevinGrandoncommented, Jun 4, 2015

@ilyavolodin - How would I submit a feature request then to split this check out from no-unused-expressions?

I think you should be able to have something which warns on "Hello world";, but does not warn on foo && foo().

KevinGrandoncommented, Jun 9, 2015

+1. I recommend creating a new rule, no-ussless-expressions as well, which would have a subset of the original functionality of the no-unused-expressions rule. I think this is the best course of action for the core project, so I will file an issue for a feature request and see what happens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-expressions - ESLint - Pluggable JavaScript Linter
This rule aims to eliminate unused expressions which have no effect on the state of the program. This rule does not apply to...
Read more >
no-unused-expression - Rule
Rule: no-unused-expression. Disallows unused expression statements. Unused expressions are expression statements which are not assignments or function calls ...
Read more >
eslint/eslint - Gitter
it seems like this should be allowed get foo() { if (condition) { return 'foo'; } }. but it's telling me I need...
Read more >
expected assignment or function call: no-unused-expressions ...
In my case I used commas instead of semicolons in constructor. Example with errors: class foo(bar1, bar2, bar3){ this.bar1=bar1, ...
Read more >
consistent-type-imports | typescript-eslint
TypeScript allows specifying a type keyword on imports to indicate that the export ... type-imports will enforce that you always use import type...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found