Skip to content

Formatting bug: Infinitely duplicating lines when formatting JSDoc @returns block with trailing text #260

@Aesthermortis

Description

@Aesthermortis

Problem statement

When formatting a JSDoc block where the trailing description (e.g., "Dialog DOM references.") appears after a type definition in a @returns annotation, the formatter introduces a bug:

  • On each format, the trailing text is moved to a new line.
  • Reapplying formatting splits this text further, creating additional lines.
  • Repeated formatting results in infinite duplication of these lines.

Example JSDoc (before formatting)

/**
 * Creates the restore dialog and its controls.
 * @returns {{
 *   fileInput: HTMLInputElement,
 *   mergeCheckbox: HTMLInputElement,
 *   overlay: HTMLDivElement,
 * }} Dialog DOM references.
 */

Result after formatting (problematic behavior)

See attached image. The formatter duplicates lines containing the trailing description each time formatting is applied.

Diff showing infinite duplication when formatting JSDoc @returns blocks

Expected behavior

  • The formatter should keep the trailing description on a single line after the type definition and not duplicate or split it after repeated formatting.

Environment

  • Repository: hosseinmd/prettier-plugin-jsdoc
  • Version: [1.8.0]
  • Prettier version: [3.8.1]
  • Node version: [25.9.0]

Steps to reproduce

  1. Use the JSDoc block shown above.
  2. Format the file using this plugin.
  3. Observe how the trailing description is split and duplicated with each additional format.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions