Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
thernstig opened this issue Feb 1, 2023 · 2 comments · Fixed by #974
Closed

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

thernstig opened this issue Feb 1, 2023 · 2 comments · Fixed by #974

Comments

@thernstig
Copy link

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
@github-actions
Copy link

github-actions bot commented Feb 3, 2023

🎉 This issue has been resolved in version 39.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@thernstig
Copy link
Author

@brettz9 I believe the logic in the PR needs to be amended a bit.

Something like this:

   * @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description -
   *    Notification description

Gets changed into this:

   * @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description - 
   *    Notification description

It is subtle, but if you check right after the - it contains a space now.

My opinion is that if there is a line break directly after the - it should not add a space, as most other formatters (Prettier) will remove it, and then you get into a loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants