- Install eslint
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
- Create .eslintignore file
touch .eslintignore
Enter:
node_modules
dist
- Create .eslintrc file
touch .eslintrc
Enter:
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"no-useless-escape": "off",
"@typescript-eslint/no-empty-function": [
"error", {
"allow": ["arrowFunctions", "constructors"]
}
],
"@typescript-eslint/ban-types": ["error",
{
"types": {
"Object": false,
"object": false,
"Function": false
},
"extendDefaults": true
}
]
}
}
- Add line (2) into package.json
1."scripts": {
2. "check": "eslint src --fix --ext .ts",
3.}
- Run eslint
npm run check
- Install prettier
npm install --save-dev prettier
npm install --save-dev eslint-config-prettier eslint-plugin-prettier
- Create .prettierrc file
touch .prettierrc
Enter:
{
"semi": true,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 120
}
- modify .eslintrc file
{
"plugins": [
"prettier" <-- add this line
],
"extends": [
"prettier" <-- add this line
],
"rules": {
"prettier/prettier": 2, <-- add this line
}
}
- Run eslint
npm run check
- npm install
- npm run webpack
- Open new terminal and run command
npm start