npm-ts-package-template
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

A template for a npm package with typescript and jest

Inspired by this article

Initial steps

  1. make new folder: mrdir project-folder && cd project-folder
  2. create README.md file: echo "# My Awesome Project" >> README.md
  3. init git repository: git init
  4. commit README.md file: git add README.md && git commit -m "initial commit"
  5. create package.json: npm init -y

Create basic configuration files:

Install some essential packages

yarn add -D @types/jest \
            @typescript-eslint/eslint-plugin \
            @typescript-eslint/parser \
            eslint \
            eslint-config-prettier \
            eslint-plugin-prettier \
            eslint-plugin-simple-import-sort \
            jest \
            nodemon \
            prettier \
            ts-jest \
            typescript

Config for typescript

tsconfig.json

ESLint Config for typescript

tsconfig.eslint.json

Prettier config

.prettierrc

ESLint config

.eslintrc.js

Create .gitignore file

.gitignore

Create new scripts in the package.json

"scripts":

{
  "build": "tsc",
  "test": "jest",
  "test:coverage": "jest --coverage --verbose",
  "watch": "nodemon --watch src --exec yarn build",
  "lint": "eslint --fix --ignore-path .gitignore src && prettier --write --ignore-path .gitignore \"./**/*.json\"",
  "prepare": "yarn build",
  "prepublishOnly": "yarn lint && yarn test",
  "preversion": "yarn lint",
  "version": "git add -A",
  "postversion": "git push && git push --tags"
}

Readme

Keywords

none

Package Sidebar

Install

npm i npm-ts-package-template

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

3.46 kB

Total Files

4

Last publish

Collaborators

  • petka17