陌上人如玉
公子世无双

vue开发微信商城项目总结之二--Eslint配置

vscode 安装eslint插件

配置自己的规则 文件–》首选项-》设置

    "eslint.autoFixOnSave": true,
    "eslint.options": {
        "configFile": "D:/................/.eslintrc.json"
    },
    "eslint.run": "onSave",
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        {
            "language": "vue",
            "autoFix": true
        },
        {
            "language": "html",
            "autoFix": true
        }

    ],

configFile为配置文件路径,

文件名称.eslintrc.json

我的配置

// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module'
  },
  env: {
    browser: true,
    "node": true,
"es6": true
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  extends: 'standard',
  // required to lint *.vue files
  plugins: [
    // 'vuefix',
    'html'
  ],
  // add your custom rules here
  'rules': {
    "no-undef":1,
    "no-new": 1,//禁止在使用new构造一个实例后不赋
    "no-tabs":0,
    "indent":1,
    "no-mixed-spaces-and-tabs": [0, false],//禁止混用tab和空格
    "camelcase": 0,//驼峰法命名
    "eqeqeq": 0,//全等
    // "indent": ["error", 4, {"SwitchCase": 1}],
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  }
}

更详细的配置查看中文文档:http://eslint.cn/docs/rules/

赞(0) 打赏
未经允许不得转载:陌上寒 » vue开发微信商城项目总结之二--Eslint配置

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

微信扫一扫

支付宝扫一扫