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

require-param rule destructuring false errors #569

Closed
jaydenseric opened this issue Jun 7, 2020 · 2 comments
Closed

require-param rule destructuring false errors #569

jaydenseric opened this issue Jun 7, 2020 · 2 comments

Comments

@jaydenseric
Copy link
Contributor

The require-param rule option checkTypesPattern currently doesn't work deeply for destructured parameters.

Expected behavior

If you use object for an @param root type but then a named type (e.g. FooBar) for one of it's destructured properties, there should be no jsdoc/require-param lint errors.

Actual behavior

There are unexpected lint errors.

ESLint Config

{
  "rules": {
    "jsdoc/require-param": "error"
  }
}

ESLint sample

This has the unexpected lint error Missing JSDoc @param "options.a.b" declaration. eslint(jsdoc/require-param):

/**
 * Description.
 * @param {object} options Options.
 * @param {FooBar} options.a A description.
 */
function foo({ a: { b } }) {}

This does not:

/**
 * Description.
 * @param {Foo} options Options.
 * @param {FooBar} options.a A description.
 */
function foo({ a: { b } }) {}

Environment

  • Node version: v14.4.0
  • ESLint version v7.2.0
  • eslint-plugin-jsdoc version: v27.0.4
@brettz9
Copy link
Collaborator

brettz9 commented Jun 9, 2020

For a workaround, you might try something

/**
 * @typedef {object} FooOptionsObject
 * @property {FooBar} a A description.
*/

/**
 * Description.
 * @param {FooOptionsObject} options Options.
 */
function foo({ a: { b } }) {}

But yeah, we need to fix this, hopefully along with #540.

hyex added a commit to hyex/eslint-plugin-jsdoc that referenced this issue Sep 6, 2020
The error mentioned in issue gajus#569 also occurred in `check-param-name` rule. So I fixed.
@brettz9 brettz9 closed this as completed in 428174d Sep 7, 2020
@gajus
Copy link
Owner

gajus commented Sep 7, 2020

🎉 This issue has been resolved in version 30.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants