Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Opinionated template for node TypeScript projects with Vite, ESLint, Prettier, Vitetest, and various Node packages. Includes a README template

License

Notifications You must be signed in to change notification settings

Tim-W-James/node-ts-template

Repository files navigation

Node TS Template

Template includes:

  • Vite: frontend build tool and dev server, configured in ./vite.config.ts
  • TypeScript: types for js. Configured in ./tsconfig.json
  • ESLint: Linter/code analyzer with plugins for TypeScript and sonarjs. Configured in ./.eslintrc.json
  • Prettier: Formatter. Configured in ./.prettierrc.json
  • Vitest: testing framework, configured in ./vite.config.ts > test
  • npm scripts (run with npm run <script>):
    • dev - starts nodemon in the terminal, which will reload on file changes
    • build - compile prod source code to ./dist
    • start - after build, run the app
    • lint - evaluate ESLint rules against source code
    • format - format source code with prettier and try to fix any ESLint errors
    • test:run - run tests
    • test:ui - run tests and display on localhost
    • test - run unit tests located in ./tests that will reload whenever files change
    • coverage - run coverage tests and output results to ./coverage

Project structure:

  • Source code: ./src
  • Tests: ./tests
  • Types: ./types

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

TODO - README.md

  • Specify the following fields with a search and replace: repo_name, project_title, project_description
  • Replace personal information with your own: Tim-W-James, tim.jameswork9800@gmail.com, https://linkedin.com/in/timothy-william-james/
  • Fill out each section of the README as needed, uncommenting/removing sections as needed.
  • Add images for the following: images/logo.png, images/screenshot.png
  • Specify the LICENSE.txt for the project

TODO - package.json, tsconfig.json, .eslintrc.json, .editorconfig

  • Specify the following fields with a search and replace: repo_name, project_title, project_description, project_keywords
  • Replace personal information with your own: Tim-W-James, Tim James
  • Set the environment of the project:
    • ES Modules (import, export):
      • Add to package.json: "type": "module"
      • Modify the scripts in package.json:
        • "dev": "nodemon --watch './**/*.ts' --watch '.env' --exec 'node --experimental-specifier-resolution=node --loader ts-node/esm' src/index.ts"
        • "start": "node --es-module-specifier-resolution=node dist/index.js"
      • Add to tsconfig.json:
        • "module": "ES6"
        • "moduleResolution" : "node
        • "lib": ["ES6"]
      • Add to .eslintrc.json: "parserOptions": { "sourceType": "module" }
    • Node CommonJS (require, exports):
      • Add to package.json: "type": "commonjs"
      • Add to tsconfig.json: "module": "commonjs"
      • Add to .eslintrc.json: "parserOptions": { "sourceType": "script" }
  • Set the target ES version (ES6 - supported by most browsers, ESNext - latest):
    • ./.eslint.json:
      • "<target>": true
      • "ecmaVersion": <target>
    • ./tsconfig.json:
      • "target": "<target>"
      • "module": "<target>"
      • "lib": ["<target>", "DOM"]
  • Do you want to commit package-lock? If yes, remove it from the ./.gitignore
  • Specify node version in the .nvmrc
  • Specify formatting and editor configuration in ./.editorconfig. Use the ./.prettierrc.json for js specific rules that are not defined in ./.editorconfig.
  • Run: npm i
  • Finally, remove/modify the sample code:
    • ./src/*
    • ./tests/*

↑ Remove everything above once setup is complete. ↑


Logo

project_title

project_description

Table of Contents
  1. About The Project
  2. Getting Started
  3. License
  4. Contact

About The Project

repo_name Screen Shot

About text.

Features

Built With

Getting Started

Installation

  1. Clone the repo

    git clone https://github.com/Tim-W-James/repo_name.git

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Email: tim.jameswork9800@gmail.com

Project Link: https://github.com/Tim-W-James/repo_name

About

Opinionated template for node TypeScript projects with Vite, ESLint, Prettier, Vitetest, and various Node packages. Includes a README template

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published