git 提交报错eslint --fix found some errors. Please fix them and try committing again...

git提交时由于eslint的检测机制报错:npm run lint-staged:js found some errors
git提交时报了两条错误:
1、stylelint --syntax less found some errors. Please fix them and try committing again
2、npm run lint-staged:js found some errors. Please fix them and try committing again.

vscode报错如下:


E:\wanghx\react-antd-pro\config\config.js
0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override

E:\wanghx\react-antd-pro\config\router.config.js
0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override

E:\wanghx\react-antd-pro\src\pages\Table\TablePagination\index.jsx
 4:10  warning  'FormattedMessage' is defined but never used  @typescript-eslint/no-unused-vars
 8:28  error    Curly braces are unnecessary here             react/jsx-curly-brace-presence
 9:17  error    Curly braces are unnecessary here             react/jsx-curly-brace-presence
19:17  error    Curly braces are unnecessary here             react/jsx-curly-brace-presence

6 problems (3 errors, 3 warnings)
3 errors and 0 warnings potentially fixable with the `--fix` option.

 第一种解决方案,在提交时加入 --no-verify参数,用来跳过检测机制,输入以下命令:

git commit --no-verify -m "提交时的注释"

另一种解决方案:
找到根目录中的.eslintignore文件,将src放入其中,以便git提交时跳过src目录中所有文件的eslint检测机制。如下

git 提交报错eslint --fix found some errors. Please fix them and try committing again..._第1张图片

build/*.js
src
public
dist

git 提交报错eslint --fix found some errors. Please fix them and try committing again..._第2张图片

 

你可能感兴趣的:(Git,git)