Add an `ignore` option to `no-unused-expressions`
See original GitHub issueWhat rule do you want to change?
no-unused-expressions
Does this change cause the rule to produce more or fewer warnings? Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
New option ignore
which takes objects’ names.
Please provide some example code that this change will affect:
import { expect } from 'chai';
const output = 1;
expect(output).to.be.NaN;
What does the rule currently do for this code?
Throws a no-unused-expressions
error on the last line.
What will the rule do after it’s changed?
/*eslint no-unused-expressions: ["error", { "ignore": ['expect'] }]*/
import { expect } from 'chai';
const output = 1;
expect(output).to.be.NaN;
// => no warning
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Nice way to get rid of no-unused-expressions linter error with ...
Put a new .eslintc configuration file in the same directory as your test files, configured to disable that rule. · Use the overrides...
Read more >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 >Solved: Optional Chaining no-unused-expressions ESLint Error
Fix for "no-unused-expressions" ESLint error when using JavaScript optional chaining. If you're seeing the " no-unused-expressions " ESLint ...
Read more >no-unused-expressions | typescript-eslint
Disallow unused expressions. ... This rule extends the base eslint/no-unused-expressions rule. It adds support for optional call expressions x?
Read more >no-unused-expression - Rule
Disallows unused expression statements. Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).
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
@eTorAken I’ve made a small plugin that overrides default
no-unused-expressions
rule and makes it friendly towards chaiexpect
statements. I hope this will help you.Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.