Verifying snippets
Turn a community snippet into a typed, tested, verified one.
Most of the collection came from QuickSnip v1, where snippets were reviewed by hand but not tested. Verifying them is the most valuable contribution right now, and a great first pull request.
Steps
- Find an unverified snippet. On /snippets, any snippet without the ✓ badge counts. JavaScript ones are the easiest start.
- In its folder, add
<name>.ts: a typed version of the code withexport. Fix any bugs you find on the way. - Add
<name>.test.tswith tests that cover normal input and edge cases. - If you replaced the
.jsfile with an equivalent.ts, delete the.jsfile. The shadcn CLI turns TypeScript into JavaScript for JS projects. - Update
meta.json: move usage examples fromusage.jstousage.ts, and add your username to the end ofcontributors. - Run
npm testandnpm run snippets:check, then open a pull request.
What reviewers look for
- Correct behavior for empty, unicode, negative, huge and invalid inputs.
- No mutation of inputs unless the name says so (
shufflereturns a new array). - Types that help the caller, not
any. - No new dependencies.
Keep the original contributors in meta.json. Verification builds on their work.