Skip to content

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

Closed
@gboer

Description

@gboer
  • [ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy