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

Bug: valid-title can't eliminate string types with settings.typecheck #681

Closed
JoshuaKGoldberg opened this issue Mar 17, 2025 · 0 comments · Fixed by #682
Closed

Bug: valid-title can't eliminate string types with settings.typecheck #681

JoshuaKGoldberg opened this issue Mar 17, 2025 · 0 comments · Fixed by #682

Comments

@JoshuaKGoldberg
Copy link
Contributor

settings.typecheck allows vitest/valid-title to skip reporting on class and function types, as determined by services.getTypeAtLocation:

if (settings.typecheck) {
const services = ESLintUtils.getParserServices(context)
const type = services.getTypeAtLocation(argument)
if (isFunctionType(type) || isClassType(type)) return
}

But if the discovered type is a string then it may still get reported on.

import { describe, test, expect } from "vitest";

declare const outerName: string;

describe(outerName, () => {
  //     ~~~~~~~~~
  // Test title must be a string, a function or class name
  test("item", () => {
    expect(0).toBe(0);
  });
});
@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: valid-title can't eliminate string types with settings.typcheck Bug: valid-title can't eliminate string types with settings.typecheck Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant