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

React+TypeScript项目ESLint持续提示no-explicit-any规则未找到如何解决

解决方案

这不是ESLint的bug,是你的ESLint配置写法错误导致的。

错误原因

no-explicit-any 并非ESLint原生提供的规则,它属于@typescript-eslint插件的专属规则,使用时必须携带@typescript-eslint/前缀才能被正确识别。你当前配置的rules字段中同时存在两条相关配置:

  • 无效配置(无前缀,ESLint无法找到对应规则,所以会全局抛出规则不存在的错误):"no-explicit-any": "error"
  • 有效配置:"@typescript-eslint/no-explicit-any": "error"

修复方法

直接删除rules配置中无前缀的"no-explicit-any": "error"这一行即可,保留带前缀的规则就能正常实现你需要的any类型校验能力,不会再触发规则不存在的报错。
修改后的rules字段示例:

"rules": {
    "import/no-anonymous-default-export": "off",
    "@typescript-eslint/no-extra-semi": "off",
    "@typescript-eslint/no-explicit-any": "error",
    "@typescript-eslint/no-unused-vars": "off",
    "@typescript-eslint/explicit-module-boundary-types": "error",
    "@typescript-eslint/no-non-null-assertion": "off",
    "@typescript-eslint/no-inferrable-types": "off",
    "@typescript-eslint/no-empty-interface": "off"
}

报错示例:
空文件报错示例

内容的提问来源于stack exchange,提问作者A-S

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.13 14:24:04