Skip to content
/ typescript-template Public template

This is a template for TypeScript related projects.

License

Notifications You must be signed in to change notification settings

bmacher/typescript-template

Repository files navigation

ci pr Dependabot Enabled

(↑ Adapt path to your repository!)

Typescript Template

This is a template for TypeScript related projects. It is already delivered with some features, which are listed below. There will also be a short description how to remove single features from the repository.

Found some stuff to fix or improve? Please fork and create a pull request or simply create an issue.

Features

Yarn

This repository uses yarn as its package manager. It is just a personal flavour.

How to remove:

  • delete yarn.lock
  • run npm install
  • (Caution! There is a npm post install hook, that may only work with yarn or npm. Other package manager haven't been tested.)

ESLint

ESLint is used as the linting tool to keep a good code style.

How to remove:

  • delete .eslintrc.js and .eslintignore
  • delete "lint" and "lint:fix" in scripts section in package.json
  • delete dependencies:
yarn remove \
  eslint \
  @bmacher/eslint-config-typescript \
  @typescript-eslint/eslint-plugin \
  @typescript-eslint/parser \
  eslint-config-airbnb-typescript \
  eslint-import-resolver-typescript \
  eslint-plugin-import \
  eslint-plugin-prettier \
  prettier

Jest

Jest is used as the test runner.

How to remove:

  • delete jest.config.js
  • delete "test", "test:verbose" and "test:coverage" in scripts section in package.json
  • delete dependencies:
yarn remove jest @jest/types ts-jest

Commit message proposal

There is a good commit convention created by Vue (Link), that has been adapted for this repository (see COMMIT_CONVENTION.md). It is utilized by using commitlint.

How to remove:

  • delete commitlint.config.js
yarn remove @commitlint/cli @commitlint/config-conventional

Local workflow control with git hooks

There are two git hooks in place to control the local workflow. Both are installed with a npm post install hook. One just verifies the commit message to match the pattern from the Commit Convention. The other one runs before git push and avoids pushing directly to master. It also runs ESLint and Jest on none wip commits (work in progress). To know how it works in general, see bmacher/ts-git-hooks.

How to remove:

  • delete hook in scripts (git-commit-msg-hook.ts, git-pre-push-hook.ts)
  • if you don't need any hook
    • delete npm-post-install-hook.ts
    • delete "postinstall" in scripts section in package.json
    • delete dependencies:
yarn remove shelljs @types/shelljs chalk

Remote workflow control with github actions

There are a github workflow in place that run ESLint, Jest, tsc and Commitlint on pushes to master and pull requests (e.g. see ci.yml). To make the master save go to: Settings (Repo) → Branch → Add rule and

  • add "master" in Branch name pattern
  • activate Require status checks to pass before merging
    • Activate lint-and-test (The action must have been executed once)
  • (activate Include administrators to be extra save)

There is also a badge that shows the status of the workflow (see line 1).

How to remove:

  • delete .github/workflows/node-ci-yml

Dependabot

Dependabot is used to keep dependencies automatically up to date. It creates a pull request for each bump and (should) resolve conflicts by itself. You could also add a workflow that comments with "@dependedabot merge" when the PR has no conflicts and can be merged.

How to remove:

  • delete .github/dependabot.yml

VS Code settings

There are some settings and recommendations of extensions to setup your VS Code properly for this repository.

How to remove:

  • delete .vscode