1. 首先需要在项目根目录下安装 eslinteslint-plugin-vue:
yarn add eslint eslint-plugin-vue -D
  1. 然后在项目根目录下创建 .eslintrc.js 文件,内容如下:
module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/vue3-essential',
    'eslint:recommended'
  ],
  parserOptions: {
    parser: 'babel-eslint'
  },
  rules: {
    // 自定义规则
  }
}
  1. package.json 中添加 lint 命令:
{
  "scripts": {
    "lint": "eslint --ext .js,.vue src"
  }
}
  1. 运行 yarn lint 命令即可进行代码检查。如果想要自动修复一些问题,可以加上 --fix 参数:
yarn lint --fix
``
vue3用yarn安装eslint代码检查的具体操作

原文地址: https://www.cveoy.top/t/topic/g8Bo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录