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

Allow rules to specify and validate their options using JSON Schema #1371

Open
bmish opened this issue Jun 6, 2020 · 1 comment
Open

Allow rules to specify and validate their options using JSON Schema #1371

bmish opened this issue Jun 6, 2020 · 1 comment

Comments

@bmish
Copy link
Member

bmish commented Jun 6, 2020

This would match ESLint behavior: https://eslint.org/docs/developer-guide/working-with-rules#options-schemas

This would likely be in a meta.schema property on each rule, the same as eslint, and using the same meta object that was under consideration in #943.

There are many benefits:

  • No more need to write code inside rules to validate their schemas (currently done today by some of our rules in a parseConfig() function)
  • Less likely to have bad data passed to rules or rules used incorrectly
  • More clear exactly what rule options are supposed to look like
@rwjblue
Copy link
Member

rwjblue commented Jun 7, 2020

Seems like a good idea to me!

IMHO, this doesn't really remove the need for parseConfig conceptually, but it would make it so that it doesn't also need to validate. Specifically, it is still very useful to be able to normalize any number of valid user-land configurations into a single format that you can rely on internally in the rule (thus avoiding repeated guards or branching logic for different types of user provided config).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants