You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

未配置vue-eslint-parser时ESLint Vue规则触发异常的疑问

eslint-plugin-vue解析器配置的矛盾问题

官方明确要求:使用eslint-plugin-vue时,必须将vue-eslint-parser设为ESLint的解析器,否则插件定义的规则不会生效。

我测试时未配置该解析器,原本预期不会触发vue/no-duplicate-attributes错误,但遇到了矛盾情况:一开始以为不会报错,却出现了该错误提示;但当我使用包含重复属性的测试Vue文件时,这个错误又没有被触发。

以下是我的配置和测试代码:

配置文件(.eslintrc.js)

// .eslintrc.js
module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/essential',
    'plugin:prettier/recommended',
  ],
  parserOptions: {
    parser: '@babel/eslint-parser',
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  },
};

测试Vue文件

// testing vue files
<template>
  <MyComponent :foo="abc" foo="dd" />
</template>

内容的提问来源于stack exchange,提问作者Bei Tang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 16:27:26