Skip to content

linter: false positive in jest/no-standalone-expect #21897

@jackstevenson

Description

@jackstevenson

What version of Oxlint are you using?

1.62.0

What command did you run?

oxlint

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "plugins": ["jest"],
  "categories": {
    "correctness": "off"
  },
  "rules": {
    "jest/no-standalone-expect": "error"
  }
}

What happened?

We have a number of tests where the assertion is defined in a helper function and Oxlint is flagging it as an error.

const assertFn = (a, b) => {
  expect(a).toBe(b); // No error
};

const assertions = {
  assertFn: (a, b) => {
    expect(a).toBe(b); // Oxc Error: `expect` must be inside of a test block.
  }
};

test('test', () => {
  assertFn(1, 1);
  assertions.assertFn(1, 1);
});

Playground repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions