Skip to content

jsdoc/implements-on-classes Correctness

This rule is turned on by default.

What it does

Reports an issue with any non-constructor function using @implements.

Why is this bad?

Constructor functions should be whether marked with @class, @constructs, or being an ES6 class constructor.

Examples

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

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

How to use

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

bash
oxlint --deny jsdoc/implements-on-classes --jsdoc-plugin
json
{
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/implements-on-classes": "error"
  }
}

References

Released under the MIT License.