vscode配置eslint

1.电脑系统 windows10专业版
2.在开发的过程中,我们可能会使用到eslint,下面我来分享一下escode配置eslint和遇到的问题。
4.在settings.json中添加如下代码:

{
 // vscode默认启用了根据文件类型自动设置tabsize的选项
 "editor.detectIndentation": false,
 // 重新设定tabsize
 "editor.tabSize": 1,
 // #每次保存的时候自动格式化 
 "editor.formatOnSave": true,
 // #每次保存的时候将代码按eslint格式进行修复
 "editor.codeActionsOnSave": {
  "source.fixAll.eslint": true
 },
 "vetur.format.defaultFormatterOptions": {
  "prettier": {
   "semi": false,
   "singleQuote": true,
   //不在结束的对象添加逗号
   "trailingComma": "none"
  },
 }
}

5.你可能会遇到如下错误:
vscode配置eslint_第1张图片

这个意思是:在方法名和刮号之间需要有一格空格

6.解决方法,在 项目.eslintrc.js中添加如下代码:

rules: {
//去除方法名和括号之后的空格
  "space-before-function-paren": 0,
  'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
 }

7.本期的分享到了这里就结束啦,希望对你有所帮助,让我们一起努力走向巅峰。

你可能感兴趣的:(vscode配置eslint)