Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Demo: add ability to configure rules #653

Open
kaicataldo opened this issue Nov 22, 2019 · 2 comments
Open

Demo: add ability to configure rules #653

kaicataldo opened this issue Nov 22, 2019 · 2 comments
Labels
demo Relates to the ESLint demo page (https://eslint.org/demo) enhancement This change enhances an existing feature of the website

Comments

@kaicataldo
Copy link
Member

Our demo is increasingly being used in the issue triage process, and I think it would be beneficial to treat it more as a “Playground” or “REPL” than just as a demo.

I believe a big win would be to add the ability to configure rules (instead of just being able to turn them on or off with their default configuration). It would allow users to create their configs interactively in the browser as well as improve sharing examples and testing bugs while triaging issues. It’s currently possible to configure them using inline comments, but this isn’t a great user experience.

I have a few ideas of how this could be achieved:

  1. We could generate inputs dynamically based on each rule’s JSON schema. I would like to take a crack at this, but the one open question I have is how to handle cases where the structure of the configuration can vary greatly (oneOf, for example).
  2. Add a text box input that allows visitors to paste in their configuration. What’s tricky about this is that we’ll have to ignore any plugins that are configured and warn on cases of malformed JSON.
  3. We could potentially do both, adding the ability to switch between them. The configuration could be stored as an object and represented in both views.

Regardless, we could then allow for exporting your configuration so that you can create the configuration in the demo and export/copy it for use in your project.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Nov 22, 2019
@kaicataldo kaicataldo added demo Relates to the ESLint demo page (https://eslint.org/demo) and removed triage An ESLint team member will look at this issue soon labels Nov 22, 2019
@kaicataldo
Copy link
Member Author

Related: #574

@kaicataldo kaicataldo added the enhancement This change enhances an existing feature of the website label Nov 22, 2019
@ilyavolodin
Copy link
Member

I explored this at some point. There's a Mozilla react component that can create a form based on JSON schema that I've tried using. Problem is, our schemas are incomplete, we don't have field names, and things like arrays are not easy to represent in a meaningful UI. Also, all of the components that I've found had very strained relationship with oneOf. I think it would be awesome to allow demo rules to be configurable, but unfortunately, I think it's significantly harder then it might seem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
demo Relates to the ESLint demo page (https://eslint.org/demo) enhancement This change enhances an existing feature of the website
Projects
None yet
Development

No branches or pull requests

2 participants