Vue中eslint自定义和Vetur插件的设置

eslint自定义

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/essential',
    '@vue/standard'
  ],
  parserOptions: {
    parser: 'babel-eslint'
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'semi': ["error", "always"],
    "prefer-const": "off",
    "no-multiple-empty-lines": "off",
    "no-unused-vars": "off",
    "prefer-promise-reject-errors": "off",
    "dot-notation": "off",
    "space-before-function-paren": "off",
    "space-infix-ops": "off",
    "quotes": "off",
    "no-useless-escap": "off",
    "no-useless-escape": "off",
    "import/first": "off",
    "no-prototype-builtins": "off",
    "vue/no-unused-components": "off",
    "eqeqeq": "off"
  }
}

Vetur插件设置

{
  // tab 大小为2个空格
  "editor.tabSize": 2,
  //禁止保存的时候格式化
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  //函数名称前 加一个空格
  "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
  //格式化插件配置,设置为vetur
  "[vue]": {
    "editor.defaultFormatter": "octref.vetur"
  },
  "vetur.format.defaultFormatterOptions": {

    "js-beautify-html": {
      // #vue组件中html代码格式化样式
      "wrap_attributes": "force-aligned", //也可以设置为“auto”,效果会不一样
      "wrap_line_length": 200,
      "end_with_newline": false,
      "semi": true,
      "singleQuote": true
    },
    "prettier": {
      //设置分号
      "semi": true,
      //双引号变成单引号
      "singleQuote": true,
      //禁止随时添加逗号,这个很重要。找了好久
      "trailingComma": "none"
    }
  },
  "[javascript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容