Skip to content
← Back to rules

jsdoc/implements-on-classes Correctness

它做什么

报告任何对非构造函数使用 @implements 的问题。

为什么这不好?

构造函数应该是 无论是标记了 @class@constructs,还是作为类构造函数。

示例

以下是此规则的错误代码示例:

javascript
/**
 * @implements {SomeClass}
 */
function quux() {}

以下是此规则的正确代码示例:

javascript
class Foo {
  /**
   * @implements {SomeClass}
   */
  constructor() {}
}
/**
 * @implements {SomeClass}
 * @class
 */
function quux() {}

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/implements-on-classes": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jsdoc"],
  rules: {
    "jsdoc/implements-on-classes": "error",
  },
});
bash
oxlint --deny jsdoc/implements-on-classes --jsdoc-plugin

版本

此规则于 v0.3.2 中添加。

参考资料