Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enhancement: Consider making custom rule 'recommended' field generic #6467

Closed as not planned
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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

Relevant Package

utils

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).

Description

Our ESLintUtils.RuleCreator function's parameter includes a recommended property. Relative to #5251:

  • Previously, that was recommended: 'error' | 'strict' | 'warn' | false property.
  • In that PR it became optional, recommended?: 'recommended' | 'strict' | 'stylistic'.

Having it optional is nicer for users because they don't have to provide one. Many users writing custom rules don't care about the recommended property. They might be writing one-of rules for a single repo, or for configs that they always configure in roughly the same way(s). No need for a recommendation.

But for users who are writing very reusable rules that should have a recommended property, they're still locked into using our 'recommended' | 'strict' | 'stylistic' type. Which might not correspond to how they organize their rule recommendations.

@bradzacher suggested in https://github.com/typescript-eslint/typescript-eslint/pull/5251/files#r1103977719:

Do we want to make this a generic and just make it default to the old value?
In our createRule function we can overwrite it with our own type so we only do this locally.

I like that strategy!

Additional Info

I don't 100% have a code example to suggest here. A bit of investigation required. 😉

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: utilsIssues related to the @typescript-eslint/utils package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions