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
相关产品推荐
相关产品推荐

