zoukankan      html  css  js  c++  java
  • vue/eslint

     
    使用最基本的vue/standard模式格式化检查代码  ->eslint-plugin-standard (最主要的就是这个包)
    如果最开始没有通过手脚架安装eslint。后期如果需要安装,执行vue add @vue/eslint 然后手动选择eslint/standard。其实会去下载 eslint-plugin-standard包
     
    1需要在vscode插件下载eslint插件。不下载该插件的话,vue代码不会有红色报错(即使是vue代码格式有错误也不会标记红色)
    2 setting.json 全局配置eslint ,配置的目的是可以eslint自动格式化|修复|保存html/js/vue代码
      // eslint设置
      "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue",
        {
          "language": "html",
          "autoFix": true
        },
        {
          "language": "javascript",
          "autoFix": true
        },
        {
          "language": "typescript",
          "autoFix": true
        },
        {
          "language": "vue",
          "autoFix": true
        }
      ],
    View Code

     3.eslintrc rules编写

    因为使用了默认的@vue/standard 默认就带了一些代码风格。eslint-plugin-standard    https://www.npmjs.com/package/eslint-plugin-standard

     比如说默认要求单引号quotes|句末无分号semi

    https://eslint.bootcss.com/docs/rules/ 

    在rules自定义规则

    • "off" 或 0 - 关闭规则
    • "warn" 或 1 - 开启规则,使用警告级别的错误:warn (不会导致程序退出)
    • "error" 或 2 - 开启规则,使用错误级别的错误:error (当被触发的时候,程序会退出) 

    数组的第一项总是规则的严重程度(数字或字符串)如 'quotes': ['error', 'single']

    单个数字或字符串(off|warn|error) "eqeqeq": 0, "curly": "error",

    rules: {
        'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
        'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
        
      }
     
  • 相关阅读:
    debian 降级
    linux 常用查看设备命令
    viewstate
    linux图形界面编程基本知识
    Java 不适合编写桌面应用
    temp
    ASP.NET中26个常用性能优化方法
    三层架构与MVC的关系
    分页查询前台HTML+后台asp.net代码
    windows身份验证登入数据库 iis 无法访问数据库
  • 原文地址:https://www.cnblogs.com/xiaoliziaaa/p/13935160.html
Copyright © 2011-2022 走看看