Giter Club home page Giter Club logo

tim-w-james / react-ts-template Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1015 KB

Opinionated template for frontend React TypeScript projects with Vite, ESLint, Prettier, Vitetest, and more. Includes a README template

License: MIT License

HTML 1.37% TypeScript 74.21% SCSS 3.68% Shell 0.69% JavaScript 12.41% CSS 7.64%
node npm template typescript eslint prettier react vite vitest biolerplate frontend hmr starter husky stylelint github-actions pnpm renovate storybook

react-ts-template's Introduction

React TS Template

Opinionated template for frontend React TypeScript projects with Vite, ESLint, Prettier, Vitetest, and more packages. This template aims to speed up the initial configuration and boilerplate for new projects, while providing integration with a range of modern tooling. This repo also includes a React starter app using Bootstrap Components and React Router 6.

Template includes:

  • React 17: frontend framework
  • Vite: frontend build tool and dev server, configured in ./vite.config.ts
  • TypeScript 4.7: types for js. Configured in ./tsconfig.json
  • SASS: CSS preprocessor
  • ESLint: Linter/code analyzer for TypeScript. Configured in ./.eslintrc.cjs with rules from AirBnB and SonarJS
  • Stylelint: Linter/code analyzer for SCSS. Configured in ./.stylelintrc.cjs
  • Prettier: Formatter. Configured in ./.prettierrc.cjs
  • Vitest: unit testing framework. Configured in ./vite.config.ts > test
  • Storybook: view, document and test individual components and pages. Configured in ./.storybook/main.cjs
  • unplugin-auto-import: global imports. Configured in ./vite.config.ts > Plugins > AutoImport
  • pnpm: configuration for the pnpm package manager for better performance, lockfiles and monorepo support. See steps below if you wish to use a different package manager.
  • npm scripts - run with pnpm run <script>:
    • dev - starts a dev environment on localhost with Hot Module Reloading (automatically updates when source code changes)
    • dev:https - starts a dev environment on localhost over https (requires local development certificates to be generated, or use vite-plugin-basic-ssl to auto generate certs)
    • build - compile production source code to ./dist
    • preview - after build, preview on localhost
    • lint - evaluate ESLint rules against source code
    • format - format source code with prettier and try to fix any ESLint errors
    • test:run - run tests using Vitest
    • test:ui - run tests and display a UI on localhost
    • test - run unit tests in watch mode (automatically reruns tests when source code changes)
    • coverage - run coverage tests and output results to ./coverage
    • storybook - launch Storybook to view, document and test components and pages
  • Husky: pre-commit Git hooks to lint, format and run tests. Configured in ./.husky
  • Renovate: GitHub bot for automatic dependency updates. Configured in ./renovate.json
  • GitHub Actions: GitHub CI/CD pipeline. Configured in ./.github/workflows
  • Starter React app with Bootstrap 5 and React Router 6
  • See the Project Structure

Complete the configuration checklist below and remove from the README once complete.

TODO

↑ Remove everything above once setup is complete. ↑


project_title

project_description


CI Commit Renovate


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Development

About The Project

About text.

Goals

  • Stuff to do

Getting Started

Prerequisites

  • Install node for the version in .nvmrc or use nvm:

    nvm install && nvm use
  • Install the pnpm package manager. Use corepack for automatic installation, which is an experimental node feature that must be enabled using:

    corepack enable

Installation

  • Clone the repo:

    git clone https://github.com/Tim-W-James/repo_name.git
  • Install dependencies with pnpm:

    pnpm i

Usage

  • Build to ./dist and preview:

    pnpm build
    pnpm preview

Development

  • Ensure you have Git Hooks enabled (should run automatically after pnpm i):

    npx husky install
  • Start a development environment:

    pnpm dev

Testing

  • Run unit tests in watch mode (automatically reruns tests when source code changes):

    pnpm test
  • Run coverage tests and output results to ./coverage:

    pnpm coverage
  • View and test individual components or pages:

    pnpm storybook

Code Style

Project Structure

  • Source Code: ./src
  • Unit Tests: place tests adjacent to source code
  • Storybook Stories: place stories adjacent to source code
  • SCSS Styling:
    • Use index.scss for globals
    • Place page or component specific styles adjacent to source code, using scoped .modules
  • Global TypeScript Types: ./types
  • Web Accessible Files (robots.txt, manifest.json, etc.): ./public
  • Site Assets (favicon.svg, images, etc.): ./public/assets. Has alias @assets

Define path alias in ./tsconfig.paths.json.

I recommend using VSCode file nesting for a cleaner file tree.

Documentation

  • Document code with JSDoc

  • Document components or pages with Storybook and run with:

    pnpm storybook

↑ Back to Top ↑

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.