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

match-description fails with a @template using a complex default value #1304

Closed
Arkellys opened this issue Aug 13, 2024 · 4 comments · Fixed by #1305 · May be fixed by Sec32fun32/eslint#3 or OKEAMAH/eslint#36
Closed

match-description fails with a @template using a complex default value #1304

Arkellys opened this issue Aug 13, 2024 · 4 comments · Fixed by #1305 · May be fixed by Sec32fun32/eslint#3 or OKEAMAH/eslint#36

Comments

@Arkellys
Copy link

Expected behavior

I expect the rule match-description do detect correctly the start of the description.

Actual behavior

The rule match-description fails to detect the description on a @template using a complex default value. Note that require-hyphen-before-param-description fails as well, but I suppose it's linked.

ESLint Config

"jsdoc/require-hyphen-before-param-description": ["warn", "always", {
  tags: {
    ...
    template: "always"
  }
}],
"jsdoc/match-description": ["warn", {
  contexts: ["any"],
  matchDescription: "^[A-Z].*[^\\.]$",
  tags: {
    ...
    template: {
      message: "@template description should begin with a capital letter and not end with a period.",
      match: true
    }
  }
}]

Full config available here.

ESLint sample

/**
 * @template {any} T - Arg 1
 * @template {string | number} K - Arg 2
 * @template {any} [R=(K extends keyof T ? T[K] : never)] - Arg 3  ->  Errors here
 * @typedef {any} Test
 */
There must be a hyphen before @template description.
@template description should begin with a capital letter and not end with a period.

Autofix of require-hyphen-before-param-description will add the hyphen after T[K].

Environment

  • Node version: 20.9.0
  • ESLint version: 8.57.0
  • eslint-plugin-jsdoc version: 48.10.2
@brettz9
Copy link
Collaborator

brettz9 commented Aug 13, 2024

Sorry about that...

Copy link

🎉 This issue has been resolved in version 50.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@brettz9
Copy link
Collaborator

brettz9 commented Aug 13, 2024

In the absence of a proper parser, I've amended @es-joy/jsdoccomment to grab the last closing bracket if a starting one is found, and treat that as the end of the "name" portion, with the rest as the "description". That should fix this particular issue, but we should really switch to a proper parser.

@Arkellys
Copy link
Author

Thank you for the super fast fix!

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