nodejs项目工程化 eslint prettier husky lint-staged commitlint commitizen
以下是一个使用了上述工具的Node.js项目的简化版package.json
文件示例:
{
"name": "your-project",
"version": "1.0.0",
"scripts": {
"format": "prettier --write .",
"lint": "eslint .",
"lint:staged": "lint-staged"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint && npm run format",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.js": "eslint --fix",
"*.ts": "eslint --fix"
},
"devDependencies": {
"eslint": "^7.20.0",
"prettier": "^2.2.1",
"husky": "^6.0.0",
"lint-staged": "^10.0.7",
"commitlint": "^11.0.0",
"commitizen": "^4.2.4"
},
"eslintConfig": {
"extends": ["some-eslint-config"]
},
"prettier": {
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 80
},
"commitlint": {
"extends": ["@commitlint/config-conventional"]
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
}
这个配置文件定义了项目的基本信息,包括脚本命令,husky钩子,lint-staged配置,以及所需依赖的版本。同时,它也包含了eslintConfig
、prettier
、commitlint
和config
部分,用于配置ESLint、Prettier、Commitlint和Commitizen。这样的配置文件提供了一个结构化的方式来管理代码质量和版本控制提交规范。
评论已关闭