位置: IT常识 - 正文

eslint常见报错及解决(eslint不起作用)

编辑:rootadmin
eslint常见报错及解决 eslint常见报错问题1:Component name "index" should always be multi-word问题2:Newline required at end of file but not found问题3:Strings must use singlequote问题4:Expected indentation of 2 spaces but found 4问题5:Expected a line break after this opening brace问题6:Trailing spaces not allowed问题7:Missing space before function parentheses问题1:Component name “index” should always be multi-word

推荐整理分享eslint常见报错及解决(eslint不起作用),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:eslint import报错,eslint报错怎么解决,eslint-loader报错,eslint parsing error,eslint-loader报错,eslint.cliengine is not,eslint with error prevention,eslint with error prevention,内容如对您有帮助,希望把文章链接给更多的朋友!

解决:在.eslintrc.js文件中的rules中添加组件命名忽略规则。这里使用index.vue作为页面入口文件,因此忽略index

rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', // 忽略个别组件命名规则 "vue/multi-word-component-names": ["error",{ "ignores": ["index"] }]}问题2:Newline required at end of file but not foundeslint常见报错及解决(eslint不起作用)

解决:在文件结尾添加换行

问题3:Strings must use singlequote

解决:

手动将双引号改成单引号为了避免格式化代码后又将单引号改回双引号,需要修改格式化文件的配置。即在项目根目录中创建.prettierrc(格式化文件配置项),并添加 "singleQuote": true,启用单引号 注:该配置项是一个json文件格式{ "singleQuote": true}问题4:Expected indentation of 2 spaces but found 4

解决:因为eslint要求2个缩进,而通常一个tab是4个缩进,改为2个缩进即可,或者在.eslintrc.js文件中的rules中关闭缩进校验"indent": 0

问题5:Expected a line break after this opening brace

解决:大括号后换行 改为

问题6:Trailing spaces not allowed

解决:存在多余空格,删除多余的空格

问题7:Missing space before function parentheses

解决:方法名和括号之间需要一个空格,可添加空格,但由于习惯写法方法名和括号间不加空格,因此可在.eslintrc.js文件中的rules中添加'space-before-function-paren': 0,将方法名和括号间空格设为0

本文链接地址:https://www.jiuchutong.com/zhishi/295361.html 转载请保留说明!

上一篇:【数据挖掘实战】——应用系统负载分析与容量预测(ARIMA模型)(数据 挖掘)

下一篇:如何使用 CSS 使表格居中(快速指南)(css怎么调用)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络