Skip to content

clover5215/react-nextjs

Repository files navigation

React + Next.js Snippets ⚛️⚡️

A compact collection of VS Code snippets for React and Next.js (JavaScript & TypeScript) — productivity shortcuts for pages, components, hooks and API routes.


Quick start ✅

  1. Install from the VS Code Marketplace (search React and Next.js Snippets) or install locally:
    • Clone the repo: git clone <repo>
    • Open in VS Code and run the Run Extension debug target or package a VSIX and install with code --install-extension <file>.vsix.
  2. Trigger any snippet by typing its prefix and pressing Tab.
  3. See the full list in SNIPPETS.md or src/extension/snippets/.

Highlights ✨

  • Ready-to-use snippets for common React patterns (functional components, hooks) and Next.js (pages, getStaticProps, API routes).
  • Supports JavaScript and TypeScript variants.
  • Small, focused, easy to extend.

Usage examples

  • Create a React functional component: type rfc (JS) or rfct (TS) + Tab.
  • Create a Next.js page: type npt (TS) or npt (JS) + Tab.

Full prefix table: see SNIPPETS.md.


Development (for contributors) 🔧

Commands

  • Install & setup hooks: yarn (or npm install)
  • Regenerate snippet docs: yarn generateReadme
  • Format: yarn format
  • Pre-commit: runs generateReadme + format (see prepare / husky)

How to add a snippet

  1. Add a JSON entry in src/extension/snippets/<language>.json (follow existing format).
  2. Run yarn generateReadme to update SNIPPETS.md and src/extension/README.md.
  3. Run yarn format and open a PR with a short description and example usage.

Local testing

  • Open the repository in VS Code and press F5 to launch an Extension Development Host where snippets are available.

Files of interest

  • src/extension/snippets/ — snippet definitions (JSON)
  • SNIPPETS.md — generated snippet table
  • src/automation/scripts/generateReadme.js — generator used by pre-commit

Audit summary — key findings (actionable) ⚠️

  1. License mismatch (HIGH)LICENSE is GPL‑3.0 but package.json lists MIT. Action: decide intended license and make them consistent (recommended: update package.json to GPL-3.0-or-later or replace LICENSE if MIT was intended).
  2. README generator: off-by-one snippet count (MEDIUM)generateReadme.js counts the header row when reporting total snippets. Fix: subtract 1 from the displayed count.
  3. README generator: race-condition (MEDIUM → HIGH for CI) — generator starts concurrent reads and writes the README from each file-callback; it can produce incomplete output. Fix: process files sequentially or use Promise.all and write only after all files are processed.
  4. Inefficient / redundant writes (LOW) — generator calls fs.writeFile(..., "") before writing final content; remove the redundant call.
  5. Documentation parity (LOW)SNIPPETS.md currently reports 38 snippets but there are 37 snippet entries across the snippet JSON files (generator bug causes +1).

Would you like me to open a PR that implements items (1)–(4)? I can prepare a minimal, well-tested patch.


Contributing 🤝

  • Read CODE_OF_CONDUCT.md and open a small PR for changes.
  • Add tests or a CI check to validate snippet JSON shape and ensure yarn generateReadme output is deterministic.

License

This repository includes a LICENSE file. Important: there is currently a mismatch between LICENSE and package.json — see Audit summary above. Please resolve before publishing.


Maintainers

  • Avneesh Agarwal (original author)

If you want, I can:

  • Apply the critical fixes and submit a PR ✅
  • Add a CI job that runs yarn generateReadme and fails if the README is out-of-date ✅

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors