Skip to content

linter: vitest/valid-describe-callback rule catches async functions incorrectly #17643

@connorshea

Description

@connorshea

What version of Oxlint are you using?

1.36.0

What command did you run?

oxlint

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

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": [
    "vitest"
  ],
  "categories": {
    "correctness": "off"
  },
  "env": {
    "builtin": true
  },
  "rules": {
    "promise/valid-params": "warn"
  },
  "overrides": [
    {
      "files": [
        "**/*.spec.ts",
        "test/**"
      ],
      "rules": {
        "vitest/valid-describe-callback": "error",
      },
      "env": {
        "vitest": true
      }
    }
  ]
}

What happened?

See https://github.com/renovatebot/renovate/blob/cf7997ad6273fdf3e147ee092083744e443c87d3/test/docs/documentation.spec.ts

I get an error on this, but it seems like - for vitest in particular based on the docs - the rule is incorrectly catching async functions as invalid here?:

  × eslint-plugin-jest(valid-describe-callback): No async describe callback
     ╭─[test/docs/documentation.spec.ts:228:41]
 227 │     
 228 │ ╭─▶     describe('docs/usage/templates.md', async () => {
 229 │ │         async function getAdditionalHandlebarsHelpersHeaders(): Promise<
 230 │ │           string[]
 231 │ │         > {
 232 │ │           const content = await fs.readFile(`docs/usage/templates.md`, 'utf8');
 233 │ │           const matches = content.match(/\n### (.*?)\n/g) ?? [];
 234 │ │           return matches.map((match) => match.substring(5, match.length - 1));
 235 │ │         }
 236 │ │   
 237 │ │         const additionalHandlebarsHelpers =
 238 │ │           await getAdditionalHandlebarsHelpersHeaders();
 239 │ │   
 240 │ │         it('has headers sorted alphabetically', () => {
 241 │ │           expect(additionalHandlebarsHelpers).toEqual(
 242 │ │             additionalHandlebarsHelpers.toSorted(),
 243 │ │           );
 244 │ │         });
 245 │ │   
 246 │ │         it('documents all added Handlebars helpers', () => {
 247 │ │           expect(additionalHandlebarsHelpers).toEqual(
 248 │ │             templateHelperNames.toSorted(),
 249 │ │           );
 250 │ │         });
 251 │ ╰─▶     });
 252 │       });
     ╰────
  help: Remove `async` keyword

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