Overview
The Stim Webtoys Library maintains high code quality through automated checks using Biome for linting and formatting, TypeScript for type checking, and Bun’s native test runner for testing.Quality Gate Commands
Full Quality Gate
Run this before committing any JS/TS changes.
- Biome check (lint + format)
- TypeScript type checking
- All tests
Quick Quality Gate
For faster iteration during development:- Biome check (lint + format)
- TypeScript type checking
Linting with Biome
The project uses Biome for fast, reliable linting.Lint Scope
Biome lints these directories:assets/scripts/tests/
Common Lint Issues
If you encounter lint drift:-
Run auto-fix:
-
Follow up with format:
Formatting with Biome
Biome also handles code formatting for consistent style.Format Scope
Biome formats these directories:assets/scripts/tests/
Type Checking with TypeScript
The project uses TypeScript for type safety without emitting compiled files.Testing with Bun
The project uses Bun’s native test runner with special configuration for Three.js and DOM testing.Running Tests
Test Types
Compatibility Tests
Fast compatibility coverage for renderer preference and fallback state logic:Full Compatibility Regression
Includes loader + toy-view flows to surface integration issues:Agent Integration Tests
Focused test for MCP/agent integration path:Test Configuration
Tests run with these important flags:--preload=./tests/setup.ts- Loads happy-dom globals for DOM testing--importmap=./tests/importmap.json- Provides Three.js stub for headless execution
bun run test.
Test Structure
Quality Expectations by Change Type
JS/TS Edits
Run
bun run check before commit.Required checks:- Biome lint/format
- TypeScript type checking
- All tests passing
Docs-Only Edits
Tests and typecheck can be skipped unless command paths/workflows changed.Recommended checks:
- Proofread
- Command/path validation
bun run check:quickif commands changed significantly
Toy Additions/Slug Changes
Run
bun run check:toys and update toy docs together.Required checks:bun run checkbun run check:toysbun run health:toys- Update toy docs (
docs/TOY_DEVELOPMENT.md,docs/TOY_SCRIPT_INDEX.md,docs/toys.md)
SEO Generation/Check Logic
Run
bun run check:seo to validate SEO artifacts.Required checks:bun run checkbun run check:seobun run generate:seoto refresh artifacts
Specialized Quality Commands
Toy Quality
SEO Quality
Pre-commit Hooks
The project uses Husky for Git hooks.Installation
Husky is installed automatically via thepostinstall script when using Bun. If it fails:
Hook Behavior
Pre-commit hooks will:- Run linting checks
- Validate formatting
- Prevent commits if checks fail
Targeted Testing Patterns
Run Single Test File
Run Tests Matching Pattern
Watch Specific Tests
Troubleshooting
Test Behavior Differs
Problem:bun run test behaves differently from direct bun test
Solution: Always invoke through package scripts so preload/importmap flags apply:
Formatting/Lint Drift
Problem: Inconsistent code style or lint errors Solution: Run fix and format in sequence:Typecheck Errors After Updates
Problem: Type errors appear after dependency changes Solution: Reinstall dependencies and recheck:check:toys Failures
Problem: Toy consistency check fails after renaming Solution: Verify all toy docs and metadata were updated together:assets/data/toys.jsondocs/TOY_DEVELOPMENT.mddocs/TOY_SCRIPT_INDEX.mddocs/toys.md
Commit Checklist
Before committing:- Run appropriate quality gate (
bun run checkorbun run check:quick) - Run specialized checks if needed (
check:toys,check:seo, etc.) - Update docs if workflows or structure changed
- Use sentence case commit message with no trailing period
- Verify all tests pass
- Ensure no lint or format issues remain
PR Checklist
Before opening a PR:- Commit title is sentence case with no trailing period
- PR description includes:
- Short summary of changes
- Explicit list of tests run
- Explicit list of docs touched/added (or “None”)
- All quality checks pass
- Docs are updated if scripts/workflows changed
- Linked docs are synchronized per
docs/DOCS_MAINTENANCE.md
Related Documentation
Getting Started
Review contribution guidelines
Development Setup
Set up your local environment