A template for Node.js & TypeScript.

typescript-starter

setting environmental variables

$ echo PORT=3000 > .env

scripts

format

$ yarn format

lint

$ yarn lint

## auto fix
$ yarn lint:fix

dev

$ yarn dev

## hot reload
$ yarn dev:watch

test

$ yarn test

build

$ yarn build

start

$ yarn start
$ curl localhost:8000
Hello World!

sling

Install various eslint related plugins.

$ yarn add -D @typescript-eslint/eslint-plugin \
  @typescript-eslint/parser \
  sling \
  eslint-config-airbnb-base \
  eslint-plugin-import

prettier

Install various prettier related plugins.

$ yarn add -D prettier \
  eslint-config-prettier

Fix to prevent conflict with eslint .eslintrc.js.

// .eslintrc.js
 extends: [
+ "prettier",
+ "prettier/@typescript-eslint",
 ]

.prettierrc.json Set as appropriate.

{
  "printWidth": 100,
  "singleQuote": true,
  "jsxSingleQuote": true,
  "trailingComma": "all"
}

is

$ yarn add -D is ts-is eslint-plugin-is @ types / is
module.exports = {
  roots: ['.'],
  transform: {
    '^.+\\.ts$': 'ts-jest',
  },
  globals: {
    'ts-jest': {
      tsConfig: './tsconfig.json',
    },
  },
};

ESLint rules for Jest

// .eslintrc.js
 env: {
   es6: true,
   node: true,
+   'is / globals': true,
 },

 // ...

- plugins: ['@typescript-eslint'],
+ plugins: ['@typescript-eslint','jest'],

Download Details:

Author: nokazn

Source Code: https://github.com/nokazn/typescript-starter

#node #nodejs #javascript #typescript

A template for Node.js & TypeScript.
8.90 GEEK