Skip to content

lines-before-block should not trigger for the first item inside functions and constructors #1379

Closed
@LukeAbby

Description

@LukeAbby

ESLint Config

{
    "jsdoc/lines-before-block": "error"
}

ESLint sample

declare class SomeClass {
  // Not ok:
  constructor(
    /** Some doc */
    param: number,
  );

  // Not ok:
  method(
    /** Some doc */
    param: number,
  ): void;

  // Ok:
  /** Some doc */
  prop: number;
}

// Not ok:
type SomeFunctionAlias =
   /**
     * @param param - Some doc.
     */
    (param: number) => void;

// Not ok:
type SomeFunctionAlias2 = (
   /**
     * @param param - Some doc.
     */
    param: number
) => void;

Environment

  • Node version: v20.15.0
  • ESLint version v9.26.0
  • eslint-plugin-jsdoc version: ^50.6.11

Expected behavior

I expected there to be a configuration option to be able to avoid having to add newlines before all of the places linted in that snippet.

Actual behavior

The rule requires adding a newline but this causes conflicts with Prettier. Subjectively I also think it looks ugly.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions