Skip to content

linter: no-standalone-expect with callback in test #11934

@Kruptein

Description

@Kruptein

What version of Oxlint are you using?

1,1,0

What command did you run?

npx oxlint

What does your .oxlintrc.json config file look like?

It's a nested config using the following root config

{
    "rules": {
        // Category: Correctness
        "eslint/no-unused-vars": ["error", {
            "ignoreRestSiblings": true
        }],
        "promise/no-callback-in-promise": "off",
        // Category: Perf
        "eslint/no-await-in-loop": "error",
        // Category: Restriction
        "eslint/default-case": "error",
        "eslint/no-alert": "warn",
        "eslint/no-console": "warn",
        "eslint/no-empty": "error",
        "eslint/no-iterator": "error",
        "eslint/no-proto": "error",
        "eslint/no-regex-spaces": "error",
        "eslint/no-unused-expressions": "error",
        "eslint/no-var": "error",
        // Category: Suspicious
        "eslint/no-extra-bind": "error",
        "eslint/no-extend-native": "error",
        "eslint/no-new": "error",
        "eslint/no-unexpected-multiline": "error",
        "eslint/no-useless-concat": "error",
        // Category: Pedantic
        "eslint/array-callback-return": ["error", { "allowImplicit": true }],
        "eslint/eqeqeq": ["error", "always", { "null": "ignore" }],
        "eslint/no-case-declarations": "error",
        "eslint/no-else-return": "error",
        "eslint/no-inner-declarations": "error",
        "eslint/no-lone-blocks": "error",
        "eslint/no-new-wrappers": "error",
        "eslint/no-prototype-builtins": "error",
        "eslint/no-self-compare": "error",
        "eslint/no-throw-literal": "error",
        "eslint/radix": "error",
        // Category: Style
        "eslint/curly": ["error", "multi-line"],
        "eslint/guard-for-in": "error",
        "eslint/no-extra-label": "error",
        "eslint/no-labels": "error",
        "eslint/no-multi-str": "error",
        "eslint/no-new-func": "error",
        "eslint/no-return-assign": "error",
        "eslint/no-script-url": "error",
        "eslint/no-template-curly-in-string": "error",
        "eslint/prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }],
        "eslint/yoda": "error",
        // Category: Nursery
        // even though this is not fully stable yet, it's an essential one
        "eslint/no-undef": "error",
        "eslint/no-unreachable": "error"
    },
    "plugins": ["unicorn", "oxc", "import", "promise"]
}

And the following package config

{
    "extends": ["../../.oxlintrc.json"],
    "env": {
        "jest": true,
        "node": true
    },
    "plugins": ["jest"]
}

What happened?

function funcWithCallback(callback) {
  callback(5);
}

describe('testWithCallback', () => {
  it('should call the callback', (done) => {
    funcWithCallback((result) => {
      expect(result).toBe(5);
      done();
    });
  });
});

This flags the expect line with the eslint-plugin-jest(no-standalone-expect) rule.

I'm not sure what the eslint behavior is in this case, but it's guaranteed running in the scope of a test block, so it doesn't seem right to me to trigger the rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions