Inform user of valid enum values when an invalid rule config value is given #6390
Labels
archived due to age
This issue has been archived; please open a new issue for any further discussion
core
Relates to ESLint's core APIs and features
enhancement
This change enhances an existing feature of ESLint
evaluating
The team will evaluate this issue to decide whether it meets the criteria for inclusion
The version of ESLint you are using.
2.11.1
The problem you want to solve.
It would be helpful to the user to list out the valid rule configuration enum values when an invalid value is given.
For example, when setting a configuration for a rule in an
.eslintrc.json
file, say for the "quotes" rule like belowIf an invalid config value is given (i.e. "backticks" instead of "backtick") the error output written to stdout looks like this
At that point the user has to look up the documentation for the rule to see that the valid options are "double", "single" or "backtick".
Your take on the correct solution to problem.
It would be helpful if the error logged something like this:
from the rule's exports.metcha.schema.enum. Perhaps a fuzzy string match could be used to make a suggestion along the lines of `
Value "backticks" must be a value of enum ["double", "single", "backtick"]. Did you mean "backtick"?
using a package like string-score
The text was updated successfully, but these errors were encountered: