ruff/playground
David Peter d51f6940fe
[ty] Playground: Better default settings (#18316)
## Summary

The playground default settings set the `division-by-zero` rule severity
to `error`. This slightly confusing because `division-by-zero` is now
disabled by default. I am assuming that we have a `rules` section in
there to make it easier for users to customize those settings (in
addition to what the JSON schema gives us).

Here, I'm proposing a different default rule-set (`"undefined-reveal":
"ignore"`) that I would personally find more helpful for the playground,
since we're using it so frequently for MREs that often involve some
`reveal_type` calls.
2025-05-26 14:14:23 +02:00
..
api Update NPM Development dependencies (#18305) 2025-05-26 07:41:37 +02:00
ruff Use git-commit as ty playground version instead of 0.0.0 (#18314) 2025-05-26 11:55:11 +00:00
shared Use git-commit as ty playground version instead of 0.0.0 (#18314) 2025-05-26 11:55:11 +00:00
ty [ty] Playground: Better default settings (#18316) 2025-05-26 14:14:23 +02:00
.gitignore Remove all useEffect usages (#12659) 2024-08-08 13:16:38 +02:00
.prettierignore Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
eslint.config.mjs Red Knot Playground (#12681) 2025-03-18 17:17:11 +01:00
package-lock.json Update NPM Development dependencies (#18305) 2025-05-26 07:41:37 +02:00
package.json Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
README.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
tsconfig.json Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
tsconfig.node.json Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00

playground

In-browser playground for Ruff. Available https://play.ruff.rs/.

Getting started

Install the NPM dependencies with npm install, and run, and run the development server with npm start --workspace ruff-playground or npm start --workspace ty-playground. You may need to restart the server after making changes to Ruff or ty to re-build the WASM module.

To run the datastore, which is based on Workers KV, install the Wrangler CLI, then run npx wrangler dev --local from the ./playground/api directory. Note that the datastore is only required to generate shareable URLs for code snippets. The development datastore does not require Cloudflare authentication or login, but in turn only persists data locally.

Architecture

The playground is implemented as a single-page React application powered by Vite, with the editor experience itself powered by Monaco.

The playground stores state in localStorage, but supports persisting code snippets to a persistent datastore based on Workers KV and exposed via a Cloudflare Worker.

The playground design is originally based on Tailwind Play, with additional inspiration from the Biome Playground.

Known issues

Stack overflows

If you see stack overflows in the playground, build the WASM module in release mode: npm run --workspace ty-playground build:wasm.