10000 Bug: [use-unknown-in-catch-callback-variable] shouldn't have `fixable` property · Issue #10988 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: [use-unknown-in-catch-callback-variable] shouldn't have fixable property #10988

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

Closed
4 tasks done
mho22 opened this issue Mar 22, 2025 · 4 comments · Fixed by #10993
Closed
4 tasks done

Bug: [use-unknown-in-catch-callback-variable] shouldn't have fixable property #10988

mho22 opened this issue Mar 22, 2025 · 4 comments · Fixed by #10993
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@mho22
Copy link
Contributor
mho22 commented Mar 22, 2025

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Rule use-unknown-in-catch-callback-variable has fixable: 'code' and hasSuggestions: true properties in meta on line 39 :

    fixable: 'code',
    hasSuggestions: true,

But each fix is located in a suggest property on line 175, 198, 224, 227 and 238 :

example on line `198 :

suggest: [
    {
        messageId: 'wrongTypeAnnotationSuggestion',
        fix: (fixer: TSESLint.RuleFixer): TSESLint.RuleFix =>
            fixer.replaceText(catchVariableTypeAnnotation, ': unknown'),
    },
],

Based on eslint documentation :

fixable: (string) Either "code" or "whitespace" if the --fix option on the command line automatically fixes problems reported by the rule.

Since fixable means "automatic fix" with --fix I suppose fixable is no more needed in this rule. Right ?

@mho22 mho22 added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Mar 22, 2025
@kirkwaiblinger
Copy link
Member

Hmm, yeah, that does field does look unused, but, thinking about it, I'm not sure why some of them aren't autofixes 🤔. Like we could definitely autofix this case:

Promise.reject('foo').catch(x => console.log(x));

Little more of a judgement call on whether we'd want to autofix something like this:

Promise.reject('foo').catch((x: string) => console.log(x));

It's safe to do so since we're just changing types but it might be annoying devx.

@kirkwaiblinger
Copy link
Member

So I guess we should pick between

  1. remove the unused "fixable": "code" attribute
  2. switch some of the suggestions to autofixes

as the resolution to this issue 🤔.

@mho22
Copy link
Contributor Author
mho22 commented Mar 22, 2025

I suppose the first suggestion could serve as a short-term fix, while the second could lead to further reflection.

@JoshuaKGoldberg
Copy link
Member

Agreed all around, it would be lovely to add fixes or suggestions to the rule. In some other issue. 🙂

@JoshuaKGoldberg JoshuaKGoldberg added good first issue Good for newcomers accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Mar 24, 2025
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Apr 4, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants
0