vscode 当我使用 vue3 时发出警告 <script setup>

vscode warn when I use vue3 <script setup>

有警告但没有提示,如何解决?

我用的是vite init项目,vue-ts模板

悬停时只警告不提示,构建也成功

我的 eslintrc :

module.exports = {
  env: {
    browser: true,
    es2021: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:vue/essential",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended",
  ],
  parserOptions: {
    ecmaVersion: 13,
    parser: "@typescript-eslint/parser",
    sourceType: "module",
  },
  plugins: ["vue", "@typescript-eslint"],
  rules: {
    // indent: ["error", 4],
    "linebreak-style": ["error", "unix"],
    quotes: ["error", "double"],
    semi: ["error", "always"],
  },
};

我已经安装了 Vue 语言特性 (Volar)

看看https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser

你有

parserOptions: {
    ecmaVersion: 13,
    parser: "@typescript-eslint/parser",
    sourceType: "module",
  }

你能试试吗

parser: "vue-eslint-parser",
parserOptions: {
    ecmaVersion: 13,
    parser: "@typescript-eslint/parser",
    sourceType: "module",
  },

您还可以查看此存储库,其中已经设置了带有 TypeScript 和 Vue 的 ESLint,并将您的配置与那里的配置进行比较:https://github.com/sethidden/vue3-eslint-stylelint-demo