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

[no-standalone-expect] False positive inside it.fails #275

Closed
KoenBrouwer opened this issue Oct 20, 2023 · 2 comments · Fixed by #276
Closed

[no-standalone-expect] False positive inside it.fails #275

KoenBrouwer opened this issue Oct 20, 2023 · 2 comments · Fixed by #276

Comments

@KoenBrouwer
Copy link
Contributor

KoenBrouwer commented Oct 20, 2023

Summary
vitest/no-standalone-expect seems to wrongly warn about an expect that is not standalone.

Steps to reproduce
Use Vitest with vitest/no-standalone-expect enabled in ESLint, run the following test:

// .eslintrc

{
    "plugins": [
        "vitest",
    ],
    "rules": {
        "vitest/no-standalone-expect": [
            "error"
        ],
    },
}
// test.ts

it.fails("should work", () => {
    expect(true).toBe(false);
});

What you expected would happen
ESLint shouldn't error on the expect, as it clearly is inside a test/it block.

What actually happens
ESLint warns/errors (depending on your setting):

it.fails("should work", () => {
    expect(true).toBe(false);
     ^^^ ESLint: Expect must be called inside a test block(vitest/no-standalone-expect)
});

Maybe related to #182?

@veritem
Copy link
Member

veritem commented Oct 21, 2023

a pr is welcome!

@KoenBrouwer
Copy link
Contributor Author

a pr is welcome!

Ah well, alright. Here you go: #276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants