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
Suggestion: add a quick-link that allows you to open a rule in the playground #17018
Comments
Hi @JoshuaKGoldberg, would love for this to be implemented in the docs. Would be super helpful! Do you think we need to generate a playground link for each option of the rule or just for the basic configuration of the rule for the user to get started with? For example, the |
An individual link for each option would be awesome, but a bit more work. The rules or their docs pages would have to have some kind of metadata for each of the options to indicate what a good setting for each option would be. So I'd propose just starting with the base rule, and treating the options as a followup issue. How does that sound to you? |
That would be great to have quick links to try out rules in playgrounds. Would the rules be added via query params? while opening in playground? cc: @eslint/eslint-tsc need suggestions on this feature implementation. |
That sounds reasonable to me 👍 |
I like the idea. In order to move forward we would first need a design to evaluate. We actually did start out with a button "Open in Playground" on code samples, which is still commented out in the code: eslint/docs/src/assets/js/main.js Line 195 in a8d0a57
The problem was that it didn't distinguish between rule code samples and others, so we just removed it. If we want to revive that we'd need to solve that problem. Because you can use inline comments to configure options, all we really need to do is encode the text in a code sample to a playground URL. (Moved this to the |
I just wonder if the "Open in Playground" on the examples is a better approach than a link at the top? |
Ah, +1 to having the "Open in Playground" on the examples. I think I'd misinterpreted your comment on why it was removed.
Do you have examples of what you mean by each? As in, what would a code block that you wouldn't want opened in the playground look like? |
Literally any code block on any page other than rule pages. :) |
Are we going to add these |
If we are going to add |
This is a really nice addition to the already great |
Oh, great, my interpretation then is that all code blocks on rule pages are good to go for this. Can do!
I'd suggest including both. A mini playground on the page isn't the same full experience as a shareable playground. Both are nice conveniences with overlapping but different sets of purposes IMO. |
@harish-sethuraman Sorry, I'm not sure what this means. Are you saying add a codeblock near the heading? I don't think adding a button near the heading like @JoshuaKGoldberg suggested makes much sense, either design-wise (there's not enough room) or usability wise (not enough context).
@amareshsm Definitely not. This would just link out to the current playground. At some point it would be great to have a mini playground; this button was seen as a stepping stone in that direction. The idea was to create a web component that anyone could use, but we just haven't been able to prioritize that work. |
Maybe this is something that can discuss in the next TSC meeting? Adding the label. |
@sam3k This discussion hasn't stalled out, so it's too early to add to the TSC meeting. Also, when flagging something for the TSC meeting, please provide the TSC Summary summarizing the issue and explaining where conversation stalled, and also the TSC Question, which is what the TSC should decide. See: https://eslint.org/docs/latest/maintain/manage-issues#when-to-send-to-tsc |
That makes sense. Will do moving forward. |
I agree it would be best to have an "Open in Playground" link on all correct and incorrect examples in rule docs. With that, I don't think we need an extra link at the top. Those code blocks are already wrapped in |
We might still need some metadata. For instance, examples for eslint/docs/src/rules/no-implicit-globals.md Lines 45 to 57 in d85efad
|
Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update. |
Folks, looks like the discussion stalled a bit. How do we move forward here? cc @eslint/eslint-team |
Since most people like the idea and I also think the same it would be great if we have a link to open a rule in the playground. We can try it out and see. @mdjermanovic thoughts? |
I'm in favor of adding an "Open in Playground" button to code blocks that represent correct and incorrect examples for rules. |
Conclusion: we can add an "open in playground" button to correct/incorrect code examples. @JoshuaKGoldberg would you like to start working on this? |
Yes, I'd love to - thanks! Very cool to see the open discussion in the thread here. If & when this lands, I'll try to bring it up with the other folks at typescript-eslint to see if we want to follow suit. |
Implemented in #17306 |
What problem do you want to solve?
It'd be nice to have a quick way to jump from a rule's docs page to trying the rule out in the playground. For example, on https://eslint.org/docs/latest/rules/require-unicode-regexp, it'd be nice to have a quick way to jump to a playground enabling the rule.
What do you think is the correct solution?
How about a Try this rule in the playground ↗ link in each rule page linking to the playground with the rule enabled in the config?
For reference, we added this to typescript-eslint.io in typescript-eslint/typescript-eslint#6085 -> typescript-eslint/typescript-eslint#6317.
Participation
Additional comments
I would love to implement this if accepted! 😄
The text was updated successfully, but these errors were encountered: