Skip to content

Prevent line break between JSDoc comment and following (non comment) statement #1211

Open
@thislooksfun

Description

@thislooksfun

Motivation

Currently it's possible to write the following code. Notice the space between
the comment and the function its describing. This is perfectly valid, but is
stylistically bad (in my opinion), and I'd like a rule to prevent (and hopefully
auto-fix) this scenario.

/**
 * This is a description of some function!
 */

function someFunction() {
   // ...
}

Current behavior

There is no such rule.

Desired behavior

I would like a new rule with the following behavior:

This should be considered an error:

/** This is a description of some function!*/

function someFunction() {}

These should not be considered errors:

/** This is a description of some function! */
// extra comment
function someFunction() {}
/** Standalone comment (e.g. a type definition) */

/** The actual description */
function someFunction() {}
/* Regular block comment */

function someFunction() {}
// Regular line comment

function someFunction() {}

Alternatives considered

This could maybe be done with other rules, but I couldn't find any other rule or combination of rules that would apply specifically to doc comments and not all block comments.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions