Skip to content

check-line-alignment not removing whitespace before start of @param description #972

@thernstig

Description

@thernstig

Expected behavior

I would have wanted the rule "jsdoc/check-line-alignment": ["warn", "never"], to remove unnecessary whitespace after the - but before the start of the description text. See ESLint sample below.

It is entirely likely that this is not a bug but a new feature request. Maybe an addition to customSpacings.

Actual behavior

ESLint sample below shows it best.

ESLint Config

{
  "root": true,
  "reportUnusedDisableDirectives": true,
  "parserOptions": {
    "ecmaVersion": 2023,
    "sourceType": "module"
  },
  "env": {
    "node": true,
    "es2022": true
  },
  "extends": ["plugin:jsdoc/recommended"],
  "plugins": ["unicorn"],
  "rules": {
    "jsdoc/require-jsdoc": "off",
    "jsdoc/require-description": "warn",
    "jsdoc/check-syntax": "warn",
    "jsdoc/check-line-alignment": ["warn", "never"],
    "jsdoc/require-hyphen-before-param-description": [
      "warn",
      "always",
      { "tags": { "property": "always" } }
    ],
    "jsdoc/require-asterisk-prefix": "warn",
    "jsdoc/tag-lines": "off", // TODO: Temporary, will be fixed soon
    "jsdoc/no-bad-blocks": ["warn", { "preventAllMultiAsteriskBlocks": true }]
  },
  "settings": {
    "jsdoc": {
      "mode": "typescript"
    }
  }
}

ESLint sample

Before linting

/**
 * Fixme
 *
 *   @param {Array}   requests - Fixme
 * @param {string} action   -   Fixme
 *
 * @returns {Array<any>} result -   Fixme
 */
function streamRequest(requests, action) {
  return [requests, action];
}

After linting with --fix

Notice the white space here - Fixme which I would have thought should become - Fixme

/**
 * Fixme
 *
 * @param {Array} requests - Fixme
 * @param {string} action -   Fixme
 *
 * @returns {Array<any>} result -   Fixme
 */
function streamRequest(requests, action) {
  return [requests, action];
}

Environment

  • Node version: v18.12.1
  • ESLint version v8.31.0
  • eslint-plugin-jsdoc version: 39.6.4

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions