美文网首页
vue 的 eslint 语法

vue 的 eslint 语法

作者: 顺其自然AAAAA | 来源:发表于2020-06-06 17:08 被阅读0次

我们在项目中启用了eslint语法规范检测,往往为了代码能够满足这样的规范,我们可以这样处理
在vs code里面设置和配置
1.安装一个插件:eslint

2.添加用户设置:文件》首选项》设置>eslint > 打开setting.json文件

3.在vs code 里面安装,装一次就行了
配置代码:

{
  "editor.fontSize": 20,
  "liveServer.settings.donotShowInfoMsg": true,
  "javascript.updateImportsOnFileMove.enabled": "always",
  "files.autoSave": "off",
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "vue-html",
    {
      "language": "vue",
      "autoFix": true
    },
    "html",
    "vue"
  ],
  "eslint.autoFixOnSave": true,
  // 需要 npm install -g eslint-plugin-vue
  "eslint.options": {
    "extensions": [
      ".js",
      ".vue"
    ]
  },
  "explorer.confirmDragAndDrop": false,
}

注意:需要 npm install -g eslint-plugin-vue

重启vs code

在package.json中加入

"rules": {
 "no-irregular-whitespace":"off",
 "vue/no-parsing-error": [2, { "x-invalid-end-tag": false }]
}

相关文章

网友评论

      本文标题:vue 的 eslint 语法

      本文链接:https://www.haomeiwen.com/subject/oymgzhtx.html