@ms918/mrm-task-lint-staged
v0.5.2
Published
mrm task 创建lint-staged
Downloads
8
Readme
@ms918/mrm-task-lint-staged
mrm task,用来配置
lint-staged
,可选 eslint 和 prettier(需要配合@ms918/mrm-task-eslint、@ms918/mrm-task-prettier)
创建的默认package.json
字段如下
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"husky": "^4.3.0"
},
"lint-staged": {
"*.{tsx,ts,jsx,js}": ["eslint --fix", "prettier --write ."],
"*.{md,mdx}": ["prettier --write ."]
}
}
默认
默认选择 eslint 和 prettier,创建配置如上。
只选择 eslint,创建配置如下
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"husky": "^4.3.0"
},
"lint-staged": {
"*.{tsx,ts,jsx,js}": ["eslint --fix"]
}
}
只选择 prettier,创建配置如下
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"husky": "^4.3.0"
},
"lint-staged": {
"*.{tsx,ts,jsx,js}": ["prettier --config .prettierrc.yml --write"],
"*.{md,mdx}": ["prettier --config .prettierrc.yml --write"]
}
}
用法
npm install -g @ms918/mrm-task-lint-staged
mrm @ms918/mrm-task-lint-staged
当执行的时候,会走下面步骤:
- 执行
@ms918/mrm-task-husky
步骤 - 判断
husky.pre-commit
是否有脚本- 有,则设置
husky.pre-commit
为之前脚本 && lint-staged
- 无,则设置
husky.pre-commit
为lint-staged
- 有,则设置
yarn
ornpm
安装lint-staged
- 设置
package.json
的lint-staged
字段为上述所示