vue 项目添加eslint 支持

作者: admin 日期: 2020-04-10 11:15:06 人气: - 评论: 0

vue cli版本 3.0


安装 @vue/cli-plugin-eslint


vue add eslint


安装好了之后我们发现项目中被自动创建了.eslintrc.js文件

package.json文件的script模块中自动加入了lint命令


修改lint命令来满足实际项目需求

"lint": "vue-cli-service lint  test src --ext .js,.vue",


修改.eslintrc.js来满足项目需求

module.exports = {
root: true,
 env: {
node: true
 },
 extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
 parserOptions: {
parser: "babel-eslint"
 },
 rules: {
'standard/array-bracket-even-spacing': 'off',
   'vue/no-unused-components': 'off',
   'vue/valid-v-bind': 'off',
   'no-undef': 'off',
   'no-debugger': 'off',
   'spaced-comment': 'off',
   'no-console': 'off',
   'vue/no-parsing-error': 'off',
   'vue/no-use-v-if-with-v-for': 'off',
   'eqeqeq': 'off',
   'no-control-regex': 'off',
   'no-cond-assign': 'off',
   'prefer-promise-reject-errors': 'off',
   'no-unused-expressions': 'off',
   'camelcase': 'off',
   'no-new': 'off',
   'standard/no-callback-literal': 'off',
   'no-unreachable': 'off',
   'no-unused-vars': 'off',
   'vue/no-unused-vars': 'off',
   'no-proto': 'off',
   'vue/require-v-for-key': 'off',
   'no-irregular-whitespace': 'off',
   'no-empty': 'off'
 }
};


执行npm run lint 就可以检查代码了


相关内容

发表评论
更多 网友评论0 条评论)
暂无评论

Copyright © 2012-2014 我的代码板 Inc. 保留所有权利。

页面耗时0.0303秒, 内存占用1.83 MB, 访问数据库13次

闽ICP备15009223号-1