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: enable settings typecheck leads to type-aware lint #664

Open
ntnyq opened this issue Feb 18, 2025 · 1 comment
Open

Bug: enable settings typecheck leads to type-aware lint #664

ntnyq opened this issue Feb 18, 2025 · 1 comment

Comments

@ntnyq
Copy link
Contributor

ntnyq commented Feb 18, 2025

As mentioned in README - Enabling with type-testing

User can enable type testing related features by setting settings.vitest.typecheck to true.

However, rule vitest/valid-title use this settings as well.

if (settings.typecheck) {
const services = ESLintUtils.getParserServices(context)
const type = services.getTypeAtLocation(argument)

It will cause ESLint error if user didn't enable type-aware lint by setting parserOptions of @typescript-eslint/plugin.

Reproduction repo

Run lint, will get:

Oops! Something went wrong! :(

ESLint: 9.20.1
Error: You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://typescript-eslint.io/getting-started/typed-linting for enabling linting with type information.
Parser: typescript-eslint/parser
Occurred while linting /Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/tests/index.test.ts:3
Rule: "vitest/valid-title"
    at throwError (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/@typescript-eslint+utils@8.24.0_eslint@9.20.1_typescript@5.7.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:38:11)
    at Object.getParserServices (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/@typescript-eslint+utils@8.24.0_eslint@9.20.1_typescript@5.7.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:27:9)
    at CallExpression (file:///Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/@vitest+eslint-plugin@1.1.31_@typescript-eslint+utils@8.24.0_eslint@9.20.1_typescript@5_d87e65acd0b63c7dc67e51c456345aea/node_modules/@vitest/eslint-plugin/dist/index.mjs:1:71138)
    at ruleErrorHandler (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/eslint@9.20.1/node_modules/eslint/lib/linter/linter.js:1160:48)
    at /Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/eslint@9.20.1/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/eslint@9.20.1/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/eslint@9.20.1/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/eslint@9.20.1/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/Users/ntnyq/Desktop/github/ntnyq/repro-perfectionist-fallback-sort/node_modules/.pnpm/eslint@9.20.1/node_modules/eslint/lib/linter/node-event-generator.js:337:14)
@ntnyq
Copy link
Contributor Author

ntnyq commented Feb 18, 2025

Maybe splitting the settings to two.

One is for type testing and the other is related to type-aware linting.

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

No branches or pull requests

1 participant