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.

Handle 'no-unused-expressions' violations due to use of Chai expect

See original GitHub issue

Using a Chai expect expression in a test with the StandardJS ESLint config will throw the ESLint error:

error  Expected an assignment or function call and instead saw an expression  no-unused-expressions

Since Chai is bundled with Cypress I think it only makes sense that eslint-plugin-cypress handle this without the user having to install a separate plugin to handle Chai expressions.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
jennifer-shehanecommented, Feb 5, 2018

Eslint decided to not address this issue as it is library specific. It seems that the best fix for this would be to add the eslint-plugin-chai-friendly plugin to our eslint config or some similar configuration to ignore chai’s no-unused-expressions. @chrisbreiding thoughts?

12reactions
ianwaltercommented, Jan 11, 2018

Sure:

const onRequest = ({ request }) => {
  expect(request.body.email.billingUpdate).to.be.true
  expect(request.body.phone.documentUpdate).to.be.false
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Nice way to get rid of no-unused-expressions linter error with ...
I've made a small plugin called eslint-plugin-chai-friendly that overrides the default ...
Read more >
tslint-no-unused-expression-chai - npm
Custom tslint no-unused-expression rule supports chai's expect assertion. ... Other type of property based assertion still may not work.
Read more >
Terms & Conditions - LILACS & CHAI
These Terms of Service state the terms and conditions of use of the services of Lilacs ... There is no refund for any...
Read more >
Testing Workflow for Web Components - DEV Community ‍ ‍
eslint-disable no-unused-expressions */ import { html, fixture, expect } ... loads the @open-wc/semantic-dom-diff chai plugin for us to use.
Read more >
ESLint, Don't Write JavaScript Without It! | Object Computing, Inc.
Error messages identify the violated rules, making it easy to adjust their ... No ? Do you use JSX? Yes ? Do you...
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