eslint 和prettier ,如果有语法错误,都会阻止代码自动格式化
相当于,需要你先解决掉语法错误之后,再自动给你格式化
原因:我使用的node版本v10.19.0node版本过低 解决办法:
require() of ES modules is not supported.
require() of /Users/wangping/learn/test-eslint/node_modules/@eslint/eslintrc/universal.js from /Users/wangping/learn/test-eslint/node_modules/eslint/lib/linter/linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/wangping/learn/test-eslint/node_modules/@eslint/eslintrc/package.json.
https://python.iitter.com/other/270726.html
原因:还是node版本
解决办法:上个问题我改为使用了node v12.16.1 版本,根据官网(https://eslint.org/docs/user-guide/getting-started)介绍,node版本需要^12.22.0, ^14.17.0, or >=16.0.0才行。
原因:npx eslint . --ext .js,.vue 后缀名可加双引号、单引号、 可不加,前面的点必须得加,不加执行没反应,也不报错。
解决方案:
原因:安装了 eslint-config-alloy 之后,会报此错误
解决办法: npm instasll -D @babel/eslint-parser 即可
其余eslint场景问题可参考网友文章:https://juejin.cn/post/7024760884421623822
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有