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

React(TypeScript)项目中ESLint与TSServer错误在诊断中重复报告的问题求助

React(TypeScript)项目中ESLint与TSServer错误在诊断中重复报告的问题求助

各位好,我最近在给我的React(TypeScript)项目配置ESLint的时候碰到了个糟心的问题:ESLint和TSServer总是会重复报告一模一样的错误(比如未使用变量这类提示),导致编辑器的诊断面板里堆了好多重复信息,看着特别乱,严重影响开发注意力。

下面是我放在项目根目录的初始eslint.config.js文件(写到hooks相关规则的时候还没完成):

// @ts-check

import eslint from "@eslint/js"
import tseslint from "typescript-eslint"
import reactPlugin from "eslint-plugin-react"
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"
import hooksPlugin from "eslint-plugin-react-hooks"
import { fixupPluginRules } from "@eslint/compat"

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  reactPlugin.configs.flat.recommended,
  eslintPluginPrettierRecommended,
  {
    plugins: {
      "react-hooks": fixupPluginRules(hooksPlugin),
    },
  },
  {
    rules: {
      // "react/react-in-jsx-scope": "off",
      // "@typescript-eslint/no-unused-vars": "warn",
      ...hooksPl...

我试着注释掉过一些规则,比如@typescript-eslint/no-unused-vars,但这样要么ESLint这边不提示了,TSServer还在重复提示;要么就是反过来,始终没法做到让两者的诊断信息不重叠。想请教下大家,有没有什么靠谱的配置方案能解决这个重复报告的问题?比如能不能让TSServer只专注处理TypeScript本身的类型检查,把代码风格、最佳实践这类交给ESLint来管?或者有没有其他的设置方式能避免这种重复提示的情况?

备注:内容来源于stack exchange,提问作者Roman Mahotskyi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.16 07:54:38