eslint常见的一些报错及解决方法
作者:qq_37344867 时间:2024-05-11 09:09:32
问题1:Component name “index” should always be multi-word
解决:在.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 found
解决:在文件结尾添加换行
问题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://blog.csdn.net/qq_37344867/article/details/126946955
标签:eslint,报错
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
一些与网页密切相关的技术
2010-09-05 21:16:00
Python flask框架实现浏览器点击自定义跳转页面
2023-04-26 15:48:31
![](https://img.aspxhome.com/file/2023/4/89274_0s.png)
在Python的Flask框架下使用sqlalchemy库的简单教程
2021-02-23 23:58:40
Django rest framework工具包简单用法示例
2022-05-17 12:00:21
MySQL数据库的事务和索引详解
2024-01-21 00:40:48
![](https://img.aspxhome.com/file/2023/5/124485_0s.png)
Python实现输入二叉树的先序和中序遍历,再输出后序遍历操作示例
2023-04-20 15:10:44
pandas.read_csv参数详解(小结)
2022-03-10 21:00:35
DB为何大量出现select @@session.tx_read_only 详解
2024-01-15 15:26:15
![](https://img.aspxhome.com/file/2023/2/126322_0s.png)
Django Form 实时从数据库中获取数据的操作方法
2024-01-23 14:35:54
![](https://img.aspxhome.com/file/2023/2/115182_0s.png)
Python Selenium异常处理的实例分析
2021-01-12 17:13:06
一文详解Python中的行为验证码验证功能
2023-04-18 02:00:56
![](https://img.aspxhome.com/file/2023/3/130833_0s.png)
Python将阿拉伯数字转换为罗马数字的方法
2022-11-15 16:07:14
Python读取JSON数据操作实例解析
2021-08-11 18:27:34
![](https://img.aspxhome.com/file/2023/4/82674_0s.png)
DVWA下载、安装、使用(漏洞测试环境搭建)的详细教程
2022-07-08 21:20:59
![](https://img.aspxhome.com/file/2023/4/131814_0s.png)
RSA加密解密算法 asp源码
2009-08-28 13:10:00
Git的使用规范流程总结
2023-03-15 06:26:59
![](https://img.aspxhome.com/file/2023/6/132246_0s.jpg)
利用Math.js解决JS计算小数精度丢失问题
2024-04-29 13:44:04
一个不错的js软键盘代码而且移植方便
2007-08-14 12:56:00
![](https://img.aspxhome.com/file/UploadPic/up/2007081413364471.jpg)
win2003上安装SQL2000时CD-KEY(序列号)无法验证解决方法
2024-01-15 16:36:19
Python光学仿真之对光的干涉理解学习
2021-05-24 04:47:52
![](https://img.aspxhome.com/file/2023/6/110406_0s.png)