Skip to content

Place auto-generated JSDoc comments above decorators/annotations #571

@seanblonien

Description

@seanblonien

Motivation

Place JSDoc in the proper location relative to decorators/annotations.

TypeScript projects frequently use decorators for classes and functions and the autofix for jsdoc/require-jsdoc places JSDoc in the wrong place.

Current behavior

Currently, the eslint fixer for the rule jsdoc/require-jsdoc places an auto-generated JSDoc in between the declaration/definition and decorator instead above the decorator like so:

@Entity('users')
/**
 *
 */
export class User {}

See the live example here.

Desired behavior

The fixer should place the auto-generated JSDoc above the decorator like so by default:

/**
 *
 */
@Entity('users')
export class User {}

Decorators are part of the definition/declaration so that's why comments should go above them.

Alternatives considered

Location of a JSDoc relative to a decorator could be made into a setting that either places the JSDoc above or below decorators.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions