Skip to content

Auto-run tests on playground load#138

Merged
thejchap merged 1 commit into
mainfrom
playground-auto-run-on-load
Jun 14, 2026
Merged

Auto-run tests on playground load#138
thejchap merged 1 commit into
mainfrom
playground-auto-run-on-load

Conversation

@thejchap

Copy link
Copy Markdown
Owner

Context

Closes #137 — when the playground loads, automatically run the tests instead of leaving an empty terminal until the user clicks Run.

Changes

  • Auto-run on load (playground/src/Editor/Chrome.tsx): a one-shot effect fires handleRun() as soon as the WASM discovery module is ready. The run spins up the Pyodide worker itself, so execution starts the moment Python can run. A didAutoRunRef guard ensures it fires only on the initial load, not on later re-renders/edits.
  • Hermetic playground lint/format pre-commit hooks (.pre-commit-config.yaml): the eslint and prettier hooks moved from bash -c 'cd playground && bun run …' (needs bun + a pre-installed node_modules) to language: node with pinned additional_dependencies, mirroring the existing markdownlint-cli2 hook so prek installs the toolchain itself.
  • CommonJS eslint config (playground/eslint.config.cjs, replacing eslint.config.js): required so the hook can resolve its plugins from prek's hermetic node env — prek exposes the env via NODE_PATH, which ESM imports ignore but require() honors. ESLint still auto-discovers the .cjs config for local eslint src/, so bun run lint is unaffected.

Test plan

  • uvx prek run eslint --all-files → Passed
  • uvx prek run prettier --all-files → Passed
  • Verified local eslint src/ auto-discovers eslint.config.cjs (the lint/format npm scripts still work).
  • Note: a full tsc/Vite build wasn't run here — the WASM toolchain (wasm-pack, wasm32 target) isn't available in this environment, and the change is a small isolated React effect that passes ESLint's rules-of-hooks/exhaustive-deps.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 14, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the playground’s first-load experience by automatically running the default tests as soon as the WASM discovery module is ready, and it updates pre-commit hooks to run ESLint/Prettier hermetically (without requiring bun or a pre-installed node_modules).

Changes:

  • Auto-run tests once on initial playground load after WASM init (Chrome.tsx).
  • Switch pre-commit ESLint/Prettier hooks to language: node with pinned additional_dependencies.
  • Replace the playground ESLint flat config from ESM (eslint.config.js) to CommonJS (eslint.config.cjs) so plugin resolution works in prek’s hermetic node environment.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
playground/src/Editor/Chrome.tsx Adds a guarded effect that triggers an initial test run once WASM is ready.
playground/eslint.config.js Removes the ESM flat config (replaced by CJS).
playground/eslint.config.cjs Adds a CJS flat config compatible with prek’s NODE_PATH-based resolution.
.pre-commit-config.yaml Updates ESLint/Prettier hooks to hermetic node environments with pinned deps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thejchap thejchap force-pushed the playground-auto-run-on-load branch 2 times, most recently from f50681c to 39a90c0 Compare June 14, 2026 20:48
Copilot AI review requested due to automatic review settings June 14, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread playground/src/Editor/Chrome.tsx
Kick off the first test run as soon as the WASM discovery module is
ready, so the playground shows live results on load instead of an empty
terminal. The run spins up the Pyodide worker itself, so execution
starts the moment Python can run. Guarded by a ref so it fires only on
the initial load.

Also make the playground eslint/prettier pre-commit hooks hermetic:
switch them from `bun run` (which needs bun + a local node_modules) to
`language: node` with pinned `additional_dependencies`, mirroring the
existing markdownlint-cli2 hook so prek installs the toolchain itself.
The eslint flat config is converted to CommonJS (eslint.config.cjs) so
it can resolve its plugins from prek's hermetic node env via NODE_PATH
(ESM imports ignore NODE_PATH; require() honors it).

Closes #137

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thejchap thejchap force-pushed the playground-auto-run-on-load branch from 39a90c0 to 242c80d Compare June 14, 2026 20:57
@thejchap thejchap merged commit aae9c2a into main Jun 14, 2026
24 checks passed
@thejchap thejchap deleted the playground-auto-run-on-load branch June 14, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-run tests on playground load

2 participants