Skip to content

@param name not recognized if on the next line after the parameter type #1348

Open
@danfuzz

Description

@danfuzz

Expected behavior

If a @param ... definition is split across multiple lines, such that there is a line break after the parameter type, the first word on the next line should be recognized as the parameter name.

Actual behavior

In this situation, the parameter name isn't recognized as such, thereby eliciting errors along these lines:

  1:1  warning  Missing JSDoc @param "foo" declaration        jsdoc/require-param
  2:1  warning  Expected @param names to be "foo". Got ""     jsdoc/check-param-names
  2:1  warning  There must be an identifier after @param tag  jsdoc/require-param-name

ESLint Config

import js from '@eslint/js';
import jsdocPlugin from 'eslint-plugin-jsdoc';
import globals from 'globals';

export default [
  js.configs.recommended,
  jsdocPlugin.configs['flat/recommended'],
  {
    languageOptions: {
      ecmaVersion: 2024,
      globals: globals.node
    },
    plugins: {
      'jsdoc': jsdocPlugin,
    },
    settings: {
      jsdoc: {
        mode: 'jsdoc'
      }
    }
  },
];

ESLint sample

/**
 * @param {string}
 *   foo The foo.
 */
export function x(foo) {
  console.log(foo);
}

As context, I've run into this when I have a @param with a type exactly long enough to warrant wrapping the parameter name onto the next line.

In case it's handy, here's a tarball of the example. You can unpack it and then run ./demo:

bug-report.tar.gz

Environment

  • Node version: 23.6.0
  • ESLint version 9.18.0
  • eslint-plugin-jsdoc version: 50.6.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions