zoukankan      html  css  js  c++  java
  • vue-cli3如何配置 eslint 及配合 vscode 自动保存

    之前多人开发项目,vue-cli3的框架,没有特别的配置eslint,导致代码写的各不相同。最近有时间鼓捣一下。

    vue-cli3如何配置eslint

    先安插件


    eslint-plugin-vue(支持vue规则)
    eslint-plugin-node(支持nodejs规则)
    eslint-plugin-import(import语句规则)
    eslint-plugin-promise
    eslint-plugin-html
    eslint-plugin-es6

    eslint-config-standard包含:

    npm install eslint-config-standard eslint-plugin-standard eslint-plugin-promise -g

     vue-cli3的eslint在 package.json文件中,我自己的配置如下

       

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    "eslintConfig": {
      "root"true,
      "env": {
        "node"true
      },
      "extends": [
        "plugin:vue/essential",
        "standard"
      ],
      "plugins": [
        "vue"
      ],
      "parserOptions": {
        "parser""babel-eslint"
      },
      "rules": {
        "prefer-const": 0,
        "generator-star-spacing""off",
        "new-cap""off"
      }
    },

     配置完了之后,看有没有报错,少什么包安什么包就是了

    vscode配置 (可以看我之前的博客 https://www.cnblogs.com/benbentu/p/9661998.html

      

     "eslint.autoFixOnSave": true,
     
    注意:eslint检查,正常vscode检测,有问题会现现红色,如果你的没有出现,看一下,vscode 右下角的eslilnt 是不是被金禁用了,打开就行了

     转载自:https://www.cnblogs.com/benbentu/  兔兔大海

  • 相关阅读:
    c++的const总结
    http框架--Forest 的使用
    SQL 语句大全
    Mysql 总结
    【Spring注解驱动开发】使用@Scope注解设置组件的作用域
    注册中心EUREKA(二)--配置列表
    Linux命令发送Http GET/POST请求
    真正理解NIO
    高并发下接口幂等性解决方案
    代码量统计工具
  • 原文地址:https://www.cnblogs.com/chenhuichao/p/14629387.html
Copyright © 2011-2022 走看看