zoukankan      html  css  js  c++  java
  • eslint配置调整

     phpstrom编辑器为例:可以在eslintrc.js中对代码的格式进行一些配置 解决代码格式不符合规则的报错

    module.exports = {
        root: true,
        env: {
            node: true
        },
        'extends': [
            'plugin:vue/essential',
            '@vue/standard'
        ],
        rules: {
            'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
            'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
            'indent': 'off',
            'space-unary-ops': 'off',             //关闭多余的空格检验
            'no-trailing-spaces': 'off',          //关闭无用的空格检测
            'semi': 'off',                        //关闭分号检测
            'space-before-function-paren': 'off',   //关闭function前的空格
            'no-multiple-empty-lines': 'off',
            'no-tabs': 'off',
        },
        parserOptions: {
            parser: 'babel-eslint'
        }
    }

     为了代码的规范化项目开发完后,要把添加的这些属于自己编辑习惯的配置注释掉或者删除掉(上面代码中红色的部分)然后在命令行执行 npm run lint 对代码格式进行初始化(前提是在package.json中有对 lint 进行配置)

    "scripts": {
        "dev": "node build/dev-server.js",
        "start": "npm run dev",
        "build": "node build/build.js",
        "lint": "eslint --fix --ext .js,.vue src"
      }, 
  • 相关阅读:
    Spring Could与Dubbo、Docker、K8S
    Spring Could 问题
    再看Spring Could微服务的关键组件
    2018第46周日
    好用的天猫精灵
    好用的微软桌面
    PostgreSQL性能极限
    微服务常见问题及解决方案
    最近看到的几本书
    程序员如何修炼管理思维
  • 原文地址:https://www.cnblogs.com/rickyctbur/p/11824337.html
Copyright © 2011-2022 走看看