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

为何ESLint会对@inheritdoc标签报错?

解决ESLint提示缺少JSDoc返回声明但已添加@inheritdoc的问题

可能原因

  • ESLint的eslint-plugin-jsdoc插件未正确识别@inheritdoc标签,或是规则配置未排除带有该标签的方法。
  • 插件版本过低,对@inheritdoc的支持不完善。

解决方案

  1. 更新插件版本
    确保eslint-plugin-jsdoc为最新版本,执行命令:

    npm update eslint-plugin-jsdoc --save-dev
    
  2. 调整ESLint规则配置
    在ESLint配置文件(如.eslintrc.json)中,修改jsdoc/require-returns规则,指定@inheritdoc为豁免标签:

    {
      "rules": {
        "jsdoc/require-returns": ["error", {
          "exemptedBy": ["inheritdoc"]
        }],
        // 可选:启用该规则帮助插件更好识别继承文档
        "jsdoc/inheritdoc": "error"
      }
    }
    
  3. 确认@inheritdoc使用正确
    确保实现类的方法上@inheritdoc标签书写规范,示例:

    export class MyBlockSource implements L2BlockSource {
      /**
       * @inheritdoc
       */
      getSyncStatus(): SyncStatus {
        // 你的实现逻辑
        return { /* SyncStatus结构内容 */ };
      }
    }
    

内容的提问来源于stack exchange,提问作者Jan Beneš

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 07:57:14