【搭建/全套解决方案/部署】vue3的后台管理系统--02--代码检测工具ESLint使用

100 阅读1分钟

首先是打开 项目中的: .eslintrc.js

这个文件中:

root: true #表示 Eslint的规则限制于当前的根本目录

node: true #表示,node环境下启动Eslint的检测,你不用就用false

'@vue/standard' #表示你用的是标准化Eslint检测

代码演示:

这个代码,规定要用单引号'',如果改成双引号"",就会报错:

改成双引号的话:

export default {
  name: "HomeView",
  components: {
    HelloWorld
  }
}

报错:说的是,你必须使用单引号, quotes表示报错的代表号

  13:9  error  Strings must use singlequote  quotes

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

如果想不报错,就可以在文件:.eslintrc.js,加上这个 'quotes': 'off'

rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'quotes': 'off'
  }

然后关闭,重启,即可消失报错,修改配置文件需要重启