如何指定JSDOC规则以识别未使用的参数?

发布于 2025-02-06 11:53:45 字数 817 浏览 1 评论 0 原文

在我的项目中,我有一个无用参数的ESLINT规则,可以通过将领先的下划线添加到参数名称中来沉默:

    /**
     * Set the outer alternative number for this context node. Default
     *  implementation does nothing to avoid backing field overhead for
     *  trees that don't need it.  Create
     *  a subclass of ParserRuleContext with backing field and set
     *  option contextSuperClass.
     *
     * @param altNumber The alt number to set.
     */
    public setAltNumber = (_altNumber: number): void => {
    };

可以覆盖此方法,这就是为什么我希望文档使用参数名称而没有领先的下划线。但是,这与Eslint 规则。

我既不想禁用未使用的参数规则,也不想禁用“要求”规则。我如何满足两者?是否有一个设置可以允许Sircker-Param即使使用领先的下划线也可以检测参数?

In my projects I have an ESLint rule for unused parameters that can be silenced by adding a leading underscore to the parameter name:

    /**
     * Set the outer alternative number for this context node. Default
     *  implementation does nothing to avoid backing field overhead for
     *  trees that don't need it.  Create
     *  a subclass of ParserRuleContext with backing field and set
     *  option contextSuperClass.
     *
     * @param altNumber The alt number to set.
     */
    public setAltNumber = (_altNumber: number): void => {
    };

This method can be overridden which is why I want the documentation to use the parameter name without the leading underscore. However, that conflicts with the ESLint jsdoc/require-param rule.

I neither want to disable the unused parameter rule nor the the require-param rule. How can I satisfy both? Is there a setting that allows require-param to detect the parameter even with a leading underscore?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪之魂 2025-02-13 11:53:45

您正在寻找 no-unundus-vars

package.json

"rules": {
    "jsdoc/require-param": ["error"],
    "no-unused-vars": ["error", {"args": "after-used"}],
},

You are looking for the no-unused-vars eslint rule.

package.json

"rules": {
    "jsdoc/require-param": ["error"],
    "no-unused-vars": ["error", {"args": "after-used"}],
},
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文