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

jsdoc/check-param-names incorrectly failing when using default params #377

Closed
OmgImAlexis opened this issue Sep 7, 2019 · 6 comments
Closed

Comments

@OmgImAlexis
Copy link
Contributor

The error I'm getting.

  ⚠  632:0  Expected @param names to be "name". Got "name ".                                     jsdoc/check-param-names
	/**
     * Loads server with { async start(), async stop() } signature
     *
     * @name core.loadServer
     * @param {string} [name = 'server'] The name of the unraid server to load.
     */
	const loadServer = async(name = 'server') => {};
@gajus
Copy link
Owner

gajus commented Sep 7, 2019

/**
 * Loads server with { async start(), async stop() } signature
 *
 * @name core.loadServer
 * @param {string} [name='server'] The name of the unraid server to load.
 */

^would work

@OmgImAlexis
Copy link
Contributor Author

I have another rule that clashes as it requires spaces like this [node = 'server].

@gajus
Copy link
Owner

gajus commented Sep 7, 2019

Sounds like a good first contribution.

@OmgImAlexis
Copy link
Contributor Author

@gajus would this be the "correct" way of fixing this? If so I'll open a PR.

diff --git a/src/rules/checkParamNames.js b/src/rules/checkParamNames.js
index 72cf61f..6675e35 100644
--- a/src/rules/checkParamNames.js
+++ b/src/rules/checkParamNames.js
@@ -40,7 +40,7 @@ const validateParameterNames = (targetTagName : string, functionParameterNames :
       return false;
     }
 
-    if (functionParameterName !== tag.name) {
+    if (functionParameterName !== tag.name.trim()) {
       const expectedNames = functionParameterNames.join(', ');
       const actualNames = paramTags.map(([, {name}]) => {
         return name;

Before:

  utils/vms/parse-domain/sanitize-vendor.js:11:NaN
  ⚠  11:0   Expected @param names to be "vendorName". Got "vendorName ".                         jsdoc/check-param-names

  utils/misc/exit-app.js:15:21
  ⚠  13:0   Expected @param names to be "error, code". Got "error, code ".                       jsdoc/check-param-names

After:
No errors.

@brettz9
Copy link
Collaborator

brettz9 commented Nov 15, 2019

Looks great to me. If you could just add the passing test, along with this config (assuming you are using async in the example), it should be good to go:

      parserOptions: {
        ecmaVersion: 2017,
      },

(While we could look at getting comment-parser to support the trimming of names itself, I think we'd probably rather not have it trim them for the sake of our fixers being able to leave such spacing alone.)

OmgImAlexis added a commit to OmgImAlexis/eslint-plugin-jsdoc that referenced this issue Dec 2, 2019
@brettz9 brettz9 closed this as completed in c361ef6 Dec 2, 2019
@gajus
Copy link
Owner

gajus commented Dec 2, 2019

🎉 This issue has been resolved in version 18.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Dec 2, 2019
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