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.
husky > pre-commit (node v12.18.4)
npm WARN lifecycle The node binary used for scripts is /var/folders/_v/t4ndg7ys48s5_bw7f5bylrbnbg8knn/T/yarn--1602729579895-0.4233597157283664/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> qianli-platform@1.0.0 lint-staged /Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src
> lint-staged
✔ Preparing...
⚠ Running tasks...
↓ No staged files match **/*.less [SKIPPED]
❯ Running tasks for **/*.{js,jsx,ts,tsx}
✖ npm run lint-staged:js [FAILED]
✔ Running tasks for **/*.{js,jsx,tsx,ts,less,md,json}
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up...
✖ npm run lint-staged:js:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! qianli-platform@1.0.0 lint-staged:js: `eslint --ext .js,.jsx,.ts,.tsx "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/VehicleDetails.tsx" "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/index.tsx" "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/service.ts" "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/utils/request.ts"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the qianli-platform@1.0.0 lint-staged:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/v_chenying07/.npm/_logs/2020-10-15T02_39_51_214Z-debug.log
> qianli-platform@1.0.0 lint-staged:js /Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src
> eslint --ext .js,.jsx,.ts,.tsx "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/VehicleDetails.tsx" "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/index.tsx" "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/service.ts" "/Users/v_chenying07/Desktop/code/qiannuo-map-update-portal-frontend/src/src/utils/request.ts"
/Users/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/VehicleDetails.tsx
8:10 error Unexpected empty object pattern no-empty-pattern
66:29 error Expected '!==' and instead saw '!=' eqeqeq
/Users/Desktop/code/qiannuo-map-update-portal-frontend/src/src/pages/ota/product/index.tsx
9:1 error Expected exception block, space or tab after '//' in comment spaced-comment
17:3 error Expected exception block, space or tab after '//' in comment spaced-comment
24:21 warning Unexpected unnamed async function func-names
76:5 error Expected exception block, space or tab after '//' in comment spaced-comment
141:23 error Expected '===' and instead saw '==' eqeqeq
/Users/Desktop/code/qiannuo-map-update-portal-frontend/src/src/utils/request.ts
33:21 error 'url' is assigned a value but never used @typescript-eslint/no-unused-vars
✖ 8 problems (7 errors, 1 warning)
3 errors and 0 warnings potentially fixable with the `--fix` option.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! qianli-platform@1.0.0 lint-staged: `lint-staged`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the qianli-platform@1.0.0 lint-staged script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/v_chenying07/.npm/_logs/2020-10-15T02_39_53_340Z-debug.log
husky > pre-commit hook failed (add --no-verify to bypass)
这两个错误都是由一个原因引起的,那便是git提交时的检测代码规范机制,详情请点击以下链接:
第一种解决方案,在提交时加入 --no-verify参数,用来跳过检测机制,输入以下命令:
git commit --no-verify -m "提交时的注释"
另一种解决方案:
找到根目录中的.eslintignore文件,将src放入其中,以便git提交时跳过src目录中所有文件的eslint检测机制。如下
build/*.js
public
dist
src