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.

Add an `ignore` option to `no-unused-expressions`

See original GitHub issue

What 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:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ihordiachenkocommented, Apr 16, 2017

@eTorAken I’ve made a small plugin that overrides default no-unused-expressions rule and makes it friendly towards chai expect statements. I hope this will help you.

1reaction
not-an-aardvarkcommented, Aug 14, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

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