Based on path

Configure baseUrl in tsconfig.json so that the path of the module reference does not need to write.. /.. /.. /.. You can write SRC/XXX directly

{
	"compilerOptions": {
		"importHelpers": true,
		"baseUrl": "src",
		"allowJs": true,
		"allowSyntheticDefaultImports": true,
		"target": "es5",
		"outDir": "dist",
		"experimentalDecorators": true,
		"lib": ["es5", "dom", "es2015.promise", "esnext"],
		"types": ["node"],
		"declaration": false,
		"sourceMap": true
	},
	"include": ["./src/**/*.ts"],
	"exclude": ["node_modules"]
}

Copy the code

configurationprettier

IO /docs/en/ins prettier. IO /docs/ docs/ ins

The installation

$ yarn add --dev --exact prettier
Copy the code

Creating a Configuration File

$ echo {}> .prettierrc.json
Copy the code

IO /docs/en/pre…

$ npm install -g mrm mrm-task-lint-staged
$ npx mrm lint-staged
Copy the code

After executing the above command, NPM scripts in package.json will be added

"prepare": "husky install"
Copy the code

And package.json adds new fields

	"lint-staged": {
		"*.{js,css,md}": "prettier --write"
	}
Copy the code

You can add the file type you want to automatically format, such as TS, TSX

IO /docs/en/int prettier/esLint

$ yarn add eslint-config-prettier -D
Copy the code

Configuration eslint

"eslintConfig": {
    "extends": [
      "prettier"
    ]
},
Copy the code

specificationcommit msg

Reference documents github.com/conventiona…

$ yarn add @commitlint/config-conventional @commitlint/cli -D
$ echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
$ npx husky add .husky/commit-msg "yarn commitlint --edit The $1"
Copy the code

Add husky configuration to package.json

"husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
Copy the code