使用ESLint校验Vue项目时,发现如下警告:
error: Newline required at end of file but not found (eol-last)
效果如下:

发现网上的解决办法,就是在警告的代码后面插入一个空行,觉得这样很不好。
无意间解决了,记录一下。
【解决】
1.把项目中有个配置文件.editorconfig,insert_final_newline=true改成false

2. .eslintrc.js中取消最后该规则的校验'eol-last': 0

重新编译,没有警告了。
在Vue项目中遇到ESLint警告'Newline required at end of file but not found',常规解决方案是在代码末尾添加空行。然而,通过修改配置文件可以避免这种手动操作。具体做法包括:1.将.editorconfig中的insert_final_newline参数设为false;2.在.eslintrc.js中禁用'eol-last'规则。应用这些更改后,重新编译项目,警告消除。
解决办法&spm=1001.2101.3001.5002&articleId=121309202&d=1&t=3&u=a602fa288ad84cad88b9b6bae96d83b6)
453

被折叠的 条评论
为什么被折叠?



