老师我有个疑问?

老师我有个疑问?

✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed

  src\router\index.js:3:1


   ^


  ✘  http://eslint.org/docs/rules/no-trailing-spaces       Trailing spaces not allowed

  src\router\index.js:9:1


   ^



✘ 2 problems (2 errors, 0 warnings)



Errors:

  1  http://eslint.org/docs/rules/no-trailing-spaces

  1  http://eslint.org/docs/rules/no-multiple-empty-lines



  ✘  http://eslint.org/docs/rules/no-trailing-spaces       Trailing spaces not allowed

  src\App.vue:3:1


   ^


  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed

  src\App.vue:3:1


   ^


  ✘  http://eslint.org/docs/rules/no-trailing-spaces       Trailing spaces not allowed

  src\App.vue:4:1


   ^


  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  Too many blank lines at the end of file. Max of 0 allowed

  src\App.vue:13:1


   ^



✘ 4 problems (4 errors, 0 warnings)



Errors:

  2  http://eslint.org/docs/rules/no-multiple-empty-lines

  2  http://eslint.org/docs/rules/no-trailing-spaces


You may use special comments to disable some warnings.

Use // eslint-disable-next-line to ignore the next line.

Use /* eslint-disable */ to ignore all warnings in a file.


老师这个警告问题,我从问答区里看到,是可以关闭的,当我项目完成后,是否可以通过npm run lint -- --fix

从新规范代码?

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕夭夭 2019-12-01 10:25:17

同学你好,npm run lint -- --fix自动修复不能解决所有问题,想去掉只能手动修复问题。例如如下提示router中的index.js第三行多了一个空行,那么自己删掉即可

http://img1.sycdn.imooc.com//climg/5de32382091d699307630175.jpg

但是一个一个的改格式很麻烦,而且完全没必要。还是建议同学按照老师上次说的,不影响代码运行可以不管它。或者关闭eslint让它不显示这些提示,即把如下配置注释。

http://img1.sycdn.imooc.com//climg/5de3246a09187db305610424.jpg

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~

好帮手慕夭夭 2019-11-04 11:40:39

你好同学,eslint是校验代码的,它校验的比较严格,例如多一个换行也会出现警告,但是这个没有任何影响,所以不使用eslint把它关闭是可以的。

也可以通过你说的命令去规范代码,不过npm run lint -- --fix规范的也不全面,可能有一些规范不了的。但是没有关系,警告不是报错,不会影响代码运行。

祝学习愉快,望采纳。

  • 提问者 慕前端5592812 #1
    老师我现在有个问题,就是后面的课程的问题,项目打包完成了,但是打包也会提醒代码不规范的警告,我通过npm run lint -- --fix处理仍没有解决?怎么办
    2019-12-01 08:09:55
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星

相似问题

登录后可查看更多问答,登录/注册

请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师