$ echo PORT=3000 > .env
$ yarn format
$ yarn lint
## auto fix
$ yarn lint:fix
$ yarn dev
## hot reload
$ yarn dev:watch
$ yarn test
$ yarn build
$ yarn start
$ curl localhost:8000
Hello World!
Install various eslint related plugins.
$ yarn add -D @typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
sling \
eslint-config-airbnb-base \
eslint-plugin-import
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"
}
$ 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'],
Author: nokazn
Source Code: https://github.com/nokazn/typescript-starter
#node #nodejs #javascript #typescript