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

Revive the no-undefined-types rule for all mods/configs #1215

Open
what1s1ove opened this issue Mar 18, 2024 · 0 comments
Open

Revive the no-undefined-types rule for all mods/configs #1215

what1s1ove opened this issue Mar 18, 2024 · 0 comments

Comments

@what1s1ove
Copy link

what1s1ove commented Mar 18, 2024

Motivation

Hey guys! First of all, thank you for such a cool and useful plugin!

This has already been discussed a bit in other issues, and I've read most of them. Here it is explained why this rule was excluded from plugin:jsdoc/recommended-typescript-error, and it was suggested using noUnusedLocals and noUnusedParameters options in the TS config. But in reality, I've encountered quite a few projects that use TS config options for linting (like noUnusedLocals or noUnusedParameters). Usually, most project tries to prefer linters for linting issues, as it's their task.

The no-unused-vars rule from the typescript-eslint plugin provides reasons why it's better to use a linter for linting rather than tsconfig options. And it seems that they are all valid. Right now, the situation is that users, when working with different ESLint plugins, have to figure out whom to trust on this issue and whom not to.

After working with eslint-plugin-jsdoc, specifically with the no-undefined-types rule, I managed to identify several cases where it doesn't mark variables through markVariableAsUsed:

Current behavior

Generics in functions

❌ Linter error: @typescript-eslint/no-unused-vars / no-unused-vars: MyOwnType in unused

/**
 * @param {<T extends unknown>(element: MyOwnType) => T} cb
 * @returns {void}
 */
const getValue = (

Template Literal Types

❌ Linter error: @typescript-eslint/no-unused-vars / no-unused-vars: MyOwnType in unused

/**
 * @param {`${'MyOwnType'}-${string}`} tagName
 * @param {CustomElementConstructor} component
 */
const defineCustomElement = (tagName, component) => {

Desired behavior

Generics in functions

/**
 * @param {<T extends unknown>(element: MyOwnType) => T} cb
 * @returns {void}
 */
const getValue = (

Template Literal Types

/**
 * @param {`${'MyOwnType'}-${string}`} tagName
 * @param {CustomElementConstructor} component
 */
const defineCustomElement = (tagName, component) => {

Perhaps I don't fully understand why it's still better not to use no-undefined-types when working with TypeScript and the recommended-typescript-flavor config. I'd be happy to hear any thoughts you have on this.

@what1s1ove what1s1ove changed the title Revive the no-undefined-types rule for all mods/configs. Revive the no-undefined-types rule for all mods/configs Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant