javascript - lint-staged 很好。但是 git commit 得到错误
问题描述
描述
当我直接使用 lint-staged 命令时,一切正常,并且没有收到错误消息。但是当我使用git commit的时候,却提示我eslint报错,没有生成任何信息。
这是使用'git commit'
husky > pre-commit (node v10.16.0)
lint-staged:bin Running `lint-staged@9.4.2` +0ms
lint-staged Loading config using `cosmiconfig` +0ms
lint-staged Successfully loaded config from `/Users/yckj2321/Documents/云从科技/frontends-js/package.json`:
lint-staged { '*.{ts,js,md,css,html}':
lint-staged [ 'prettier --write',
lint-staged './node_modules/.bin/eslint --fix',
lint-staged 'git add' ] } +29ms
lint-staged:cfg Validating config +0ms
Running lint-staged with the following config:
{
'*.{ts,js,md,css,html}': [
'prettier --write',
'./node_modules/.bin/eslint --fix',
'git add'
]
}
lint-staged:run Running all linter scripts +0ms
lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ] +0ms
lint-staged:run Resolved git directory to be `/Users/yckj2321/Documents/云从科技/frontends-js` +75ms
lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only' ] +74ms
lint-staged:run Loaded list of staged files in git:
lint-staged:run [ 'packages/cloudwalk-project-manage/postinstall.js' ] +31ms
lint-staged:gen-tasks Generating linter tasks +0ms
lint-staged:gen-tasks Generated task:
lint-staged:gen-tasks { pattern: '*.{ts,js,md,css,html}',
lint-staged:gen-tasks commands:
lint-staged:gen-tasks [ 'prettier --write',
lint-staged:gen-tasks './node_modules/.bin/eslint --fix',
lint-staged:gen-tasks 'git add' ],
lint-staged:gen-tasks fileList:
lint-staged:gen-tasks [ '/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] } +12ms
Stashing changes... [started]
lint-staged:git Running git command [ 'status', '--porcelain' ] +54ms
Stashing changes... [skipped]
→ No partially staged files found...
Running tasks... [started]
Running tasks for *.{ts,js,md,css,html} [started]
lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'prettier --write', './node_modules/.bin/eslint --fix', 'git add' ] +0ms
prettier --write [started]
lint-staged:task cmd: prettier +0ms
lint-staged:task args: [ '--write',
'/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] +0ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
prettier --write [completed]
./node_modules/.bin/eslint --fix [started]
lint-staged:task cmd: ./node_modules/.bin/eslint +461ms
lint-staged:task args: [ '--fix',
'/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] +0ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
./node_modules/.bin/eslint --fix [failed]
→
Running tasks for *.{ts,js,md,css,html} [failed]
→
Running tasks... [failed]
✖ ./node_modules/.bin/eslint --fix found some errors. Please fix them and try committing again.
husky > pre-commit hook failed (add --no-verify to bypass)
这只是'lint-staged --debug'
> frontends-js@ lint-staged /Users/yckj2321/Documents/云从科技/frontends-js
> lint-staged --debug
lint-staged:bin Running `lint-staged@9.4.2` +0ms
lint-staged Loading config using `cosmiconfig` +0ms
lint-staged Successfully loaded config from `/Users/yckj2321/Documents/云从科技/frontends-js/package.json`:
lint-staged { '*.{ts,js,md,css,html}':
lint-staged [ 'prettier --write',
lint-staged './node_modules/.bin/eslint --fix',
lint-staged 'git add' ] } +10ms
lint-staged:cfg Validating config +0ms
Running lint-staged with the following config:
{
'*.{ts,js,md,css,html}': [
'prettier --write',
'./node_modules/.bin/eslint --fix',
'git add'
]
}
lint-staged:run Running all linter scripts +0ms
lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ] +0ms
lint-staged:run Resolved git directory to be `/Users/yckj2321/Documents/云从科技/frontends-js` +153ms
lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only' ] +153ms
lint-staged:run Loaded list of staged files in git:
lint-staged:run [ 'packages/cloudwalk-project-manage/postinstall.js' ] +17ms
lint-staged:gen-tasks Generating linter tasks +0ms
lint-staged:gen-tasks Generated task:
lint-staged:gen-tasks { pattern: '*.{ts,js,md,css,html}',
lint-staged:gen-tasks commands:
lint-staged:gen-tasks [ 'prettier --write',
lint-staged:gen-tasks './node_modules/.bin/eslint --fix',
lint-staged:gen-tasks 'git add' ],
lint-staged:gen-tasks fileList:
lint-staged:gen-tasks [ '/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] } +31ms
Stashing changes... [started]
lint-staged:git Running git command [ 'status', '--porcelain' ] +90ms
Stashing changes... [skipped]
→ No partially staged files found...
Running tasks... [started]
Running tasks for *.{ts,js,md,css,html} [started]
lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'prettier --write', './node_modules/.bin/eslint --fix', 'git add' ] +0ms
prettier --write [started]
lint-staged:task cmd: prettier +0ms
lint-staged:task args: [ '--write',
'/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] +1ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
prettier --write [completed]
./node_modules/.bin/eslint --fix [started]
lint-staged:task cmd: ./node_modules/.bin/eslint +920ms
lint-staged:task args: [ '--fix',
'/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] +0ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
./node_modules/.bin/eslint --fix [completed]
git add [started]
lint-staged:task cmd: git +3s
lint-staged:task args: [ 'add',
'/Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js' ] +1ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
git add [completed]
Running tasks for *.{ts,js,md,css,html} [completed]
Running tasks... [completed]
lint-staged tasks were executed successfully! +4s
猜测
l 更改它工作正常的“预提交”挂钩。
"husky": {
"hooks": {
"pre-commit": "eslint --fix --debug /Users/yckj2321/Documents/云从科技/frontends-js/packages/cloudwalk-project-manage/postinstall.js",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS -x @commitlint/config-conventional"
}
},
解决方案
推荐阅读
- elasticsearch - 没有post body的Elasticsearch请求查询(不允许添加body)
- c# - .Net Core 多项目 docker build
- haskell - 为什么 Data.Time.Clock.POSIX 中的 getCurrentTime 函数不能按预期工作?
- android - unity是否加载存储在 android 设备内部存储中的 3d 模型?
- jquery - Laravel 错误:未定义的变量 - rating_points
- c# - 如何为 zxing 库中的数据矩阵图像生成设置 2D 数据矩阵格式
- google-cloud-platform - GCP 实例在帐户/帐单升级后消失
- python - ZMQ 丢弃旧消息
- javascript - 使用 clearInterval 清除计时器不起作用
- javascript - 是否可以使用“HERE Maps API for JavaScript”以可接受的性能呈现邮政编码边界?