Prettier A code formatter used here for Typescript
NOTE: Format on Save must be set on VSCode and configured to prettier
Packages:
-
npm install --save-dev eslint eslint-config-airbnb-base @typescript-eslint/eslint-plugin @typescript-eslint/parser
-
npm install --save-dev prettier
. Optionallynpm install --save-dev eslint-plugin-jest
-
To configure Prettier to work with ESLint:
npm install --save-dev eslint-config-prettier eslint-plugin-prettier eslint-plugin-import
-
eslintrc.json must know where to find the
tsconfig.json
configuration file. This is set in theparserOptions
section:"project": ["tsconfig.json"]
-
Add scripts to format and lint:
"format": "prettier --write src/**/*.ts{,x}"
and"lint": "tsc --noEmit && eslint src/**/*.ts{,x}"
-
Add a
.prettierignore
file to exclude build, dist and public directories -
To run this simple project run
npm run watch
that will keep an eye on the .ts files and at the same time runnpm run dev
which is the nodemon watching the changes on the compiled javascript file