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

Add meta.fixable property to each rule #6099

Closed
ybiquitous opened this issue May 19, 2022 · 2 comments · Fixed by #6181
Closed

Add meta.fixable property to each rule #6099

ybiquitous opened this issue May 19, 2022 · 2 comments · Fixed by #6181
Labels
status: ready to implement is ready to be worked on by someone type: enhancement a new feature that isn't related to rules

Comments

@ybiquitous
Copy link
Member

ybiquitous commented May 19, 2022

What is the problem you're trying to solve?

Similar discussion: #5842

If each rule would have metadata about autofixable or not, I think it would be useful for the following cases:

  • the built-in verbose formatter could suggest autofixable rules if the rules errors are found
  • custom formatters could make the Stylelint report more rich

What solution would you like to see?

It just adds the autofixable boolean property to the RuleMeta type as below:

export type RuleMeta = {
url: string;
deprecated?: boolean;
};

export type RuleMeta = {
	url: string;
	deprecated?: boolean;
+	autofixable?: boolean;
};

Perhaps, the name autofixable may be debatable (fixable is better?). Please give me feedback, if any.

@ybiquitous ybiquitous added status: needs discussion triage needs further discussion type: enhancement a new feature that isn't related to rules labels May 19, 2022
@JounQin
Copy link
Member

JounQin commented May 26, 2022

https://eslint.org/docs/developer-guide/working-with-rules#rule-basics

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

Important: the fixable property is mandatory for fixable rules. If this property isn't specified, ESLint will throw an error whenever the rule attempts to produce a fix. Omit the fixable property if the rule is not fixable.

And also, hasSuggestions and report ({ suggest: [] }) are good to have.

@jeddy3 jeddy3 changed the title Add meta.autofixable property to each rule Add meta.fixable property to each rule Jun 6, 2022
@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone and removed status: needs discussion triage needs further discussion labels Jun 6, 2022
@jeddy3
Copy link
Member

jeddy3 commented Jun 6, 2022

fixable?: boolean;

SGTM. We aren't interested in whitespace anymore and we only use the auto fixable word in our docs, whereas the command itself is fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone type: enhancement a new feature that isn't related to rules
Development

Successfully merging a pull request may close this issue.

3 participants