Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@typescript-eslint/no-misused-promises] Regression - false positive for mocha 'it' functions in version 5.13.0? #4640

Closed
gboer opened this issue Mar 7, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@gboer
Copy link

gboer commented Mar 7, 2022

  • [ x ] I have tried restarting my IDE and the issue persists.
  • [ x ] I have updated to the latest version of the packages.
  • [ x ] I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/no-misused-promises": ["error"]
  }
}
import {expect} from 'chai';

describe('An example', () => {
  it('can be an example!', async () => {
    expect(await Promise.resolve(true)).to.equal(true);
  });
});

tsconfig.json:

{
  "compilerOptions": {
    "lib": [
      "ES2021"
    ],
    "module": "CommonJS",
    "moduleResolution": "node"
  },
  "include": [
    "**/*.ts"
  ]
}

Expected Result

I expect the rule to not throw errors for the 'it' functions of Chai, since it has (this: Context) => PromiseLike<any> as its signature. No error is thrown for version 5.12.1 and earlier, of @typescript-eslint/eslint-plugin + parser.

Actual Result

<my path>/test.ts
  4:28  error  Promise returned in function argument where a void return was expected  @typescript-eslint/no-misused-promises

✖ 1 problem (1 error, 0 warnings)

Versions

package version
@typescript-eslint/eslint-plugin 5.13.0
@typescript-eslint/parser 5.13.0
TypeScript 4.5.5
ESLint 8.10.0
node 16.13.2
@gboer gboer added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 7, 2022
@JoshuaKGoldberg
Copy link
Member

Duplicate of #4609. The fix in #4620 will be released later today. Please search through closed issues as well as open ones when filing an issue.

Also, in case this is useful information, the describe and it functions in your example come from Mocha the test runner, not Chai the test assertions library.

@JoshuaKGoldberg JoshuaKGoldberg added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Mar 7, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title [@typescript-eslint/no-misused-promises] Regression - false positive for chai 'it' functions in version 5.13.0? [@typescript-eslint/no-misused-promises] Regression - false positive for mocha 'it' functions in version 5.13.0? Mar 7, 2022
@gboer
Copy link
Author

gboer commented Mar 7, 2022

ah, apologies @JoshuaKGoldberg. I went through the closed issues, but unfortunately couldn't find it. Glad to see that it is picked up already!

And yes, you're indeed right about it coming from Mocha instead of Chai. My bad.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants