oxc-project/oxc · error · OxcDiagnostic
`@implements` used on a non-constructor function
Error message
`@implements` used on a non-constructor function
What it means
Fires from jsdoc/implements-on-classes when an @implements tag is attached to a plain function rather than a class or constructor. The run visitor checks the node nearest the JSDoc comment; the helper's advice is to add @class or use class syntax.
Source
Thrown at crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs:14
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{
AstNode,
context::LintContext,
rule::Rule,
utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
};
fn implements_on_classes_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`@implements` used on a non-constructor function")
.with_help("Add `@class` tag or use class syntax.")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct ImplementsOnClasses;
declare_oxc_lint!(
/// ### 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 a class constructor.
///
/// ### ExamplesView on GitHub (pinned to e1e7af627c)
Solutions
- Convert the function to a class since @implements describes class contracts
- Add a `@class` tag if the function genuinely acts as a class
- Remove the `@implements` tag
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs:14 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/0b38bbbfbb050907.
Report an issue: GitHub.