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-description with descriptionStyle: body produces "Missing JSDoc block description" when @description is used #608

Closed
joeyparrish opened this issue Jul 9, 2020 · 5 comments · Fixed by #609

Comments

@joeyparrish
Copy link

Expected behavior

When I set the descriptionStyle: 'body' option on jsdoc/require-description, and my code uses @description instead of omitting it, I expect to get a message that indicates I should not use that tag.

Actual behavior

Instead the error says "Missing JSDoc block description", which I find misleading and unhelpful.

ESLint Config

module.exports = {
  extends: ['plugin:jsdoc/recommended'],
  rules: {
    'jsdoc/require-description': ['error', {descriptionStyle: 'body'}],
  },
};

ESLint sample

/** @description Foo! */
function foo() {}

Environment

  • Node version: v10.21.0
  • ESLint version v7.4.0
  • eslint-plugin-jsdoc version: v29.1.3
@joeyparrish
Copy link
Author

I think I have a patch that I'm happy with, but I haven't spent the time to figure out the project's tests and update those. Here's what I've done in requireDescription.js:

    if (descriptionStyle === 'body') {
      const descTags = _lodash.default.filter(jsdoc.tags,
          (tag) => tag.tag == 'desc' || tag.tag == 'description');
      if (descTags.length) {
        const tagName = descTags[0].tag;
        report(`Remove the @${tagName} tag from the block description`);
      } else {
        report('Missing JSDoc block description.');
      }
      return;
    }

Whichever of the two description tags you used, it will tell you explicitly to remove it. What do you think?

@brettz9
Copy link
Collaborator

brettz9 commented Jul 10, 2020

This should be helpful, thanks. Hope to take a look in the next day or so.

@brettz9
Copy link
Collaborator

brettz9 commented Jul 11, 2020

Currently, the descriptionStyle option, even when set to the specific "body" or "tag" case, only insists that the desired style is present. It doesn't complain--and your solution doesn't either--about a user having both. For example, this:

/**
 * Block style description
 * @desc And a tag style description
*/

...will satisfy any of the conditions and will not be reported.

So, I think the message should not instruct the user to remove the @desc style (in case they want both for some reason--since the option isn't designed to force only one style, but to merely require one or the other (or either)). But it might be reworded like:

`Remove the @${tagName} tag to leave a plain block description or add additional description text above the @${tagName} line.`

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 11, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 12, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jul 13, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes gajus#608
brettz9 added a commit that referenced this issue Jul 13, 2020
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes #608 (#609)
@gajus
Copy link
Owner

gajus commented Jul 13, 2020

🎉 This issue has been resolved in version 29.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jul 13, 2020
@joeyparrish
Copy link
Author

Thank you so much for the fix! I appreciate your time and attention.

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