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

Inform user of valid enum values when an invalid rule config value is given #6390

Closed
ejfrancis opened this issue Jun 12, 2016 · 5 comments
Closed
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

Comments

@ejfrancis
Copy link

ejfrancis commented Jun 12, 2016

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 below

{
  "rules": {
    "quotes": [2, "backtick"]
  }
}

If an invalid config value is given (i.e. "backticks" instead of "backtick") the error output written to stdout looks like this

Error: /home/user/xyz/.eslintrc.json:
    Configuration for rule "quotes" is invalid:
    Value "backticks" must be an enum value.

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:

Error: /home/user/xyz/.eslintrc.json:
    Configuration for rule "quotes" is invalid:
    Value "backticks" must be a value of enum ["double", "single", "backtick"] .

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

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 12, 2016
@platinumazure
Copy link
Member

👍 from me. Every little bit helps.

@platinumazure platinumazure added enhancement This change enhances an existing feature of ESLint core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jun 12, 2016
@mysticatea
Copy link
Member

I'm not familiar with the validation logic, but I guess the message was generated by is-my-json-valid package.

@btmills
Copy link
Member

btmills commented Jul 6, 2016

@mysticatea is correct that the schema validation error messages are coming directly from is-my-json-valid. I think it's a great idea though, would you mind filling an issue over there @ejfrancis?

@ejfrancis
Copy link
Author

@btmills no problem, I just filed an issue over in the is-my-json-valid repo

@kaicataldo
Copy link
Member

I'm closing this issues because it looks like consensus couldn't be reached. While we wish we could accommodate all requests, we have limited resources and do need to prioritize. We've found that issues failing to reach consensus after 21 days tend to never reach consensus, and as a team have decided to close such issues. This doesn't mean the idea isn't interesting or valuable, only that it's not something the team can commit to at the moment.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

No branches or pull requests

6 participants