Skip to content

Enhancement: [ban-types] Add suggest option to types #6875

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
NotWoods opened this issue Apr 9, 2023 · 0 comments · Fixed by #6876
Closed
4 tasks done

Enhancement: [ban-types] Add suggest option to types #6875

NotWoods opened this issue Apr 9, 2023 · 0 comments · Fixed by #6876
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@NotWoods
Copy link
Contributor

NotWoods commented Apr 9, 2023

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/ban-types

Description

Sometimes a banned type can support an autofix, but you'd prefer to pass an array of potential replacements rather than one autofix.

Updating the Types option to:

{
  message: string;
  fixWith?: string;
+ suggest?: readonly string[];
}

would allow for replacements to be show as ESLint suggestions.

This would also allow the default Object and {} banned types to use suggestions.

Fail

function foo(x: {}) {}

Pass

function foo(x: object) {} // replaced by using ESLint suggestion

Additional Info

No response

@NotWoods NotWoods added enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 9, 2023
@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Apr 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2023
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 enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants