Skip to content

checkDestructured property to disable destructured checks #532

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

Merged
merged 1 commit into from
May 13, 2020

Conversation

brettz9
Copy link
Collaborator

@brettz9 brettz9 commented May 11, 2020

Currently builds on #531

Allows disabling of destructured checks (by setting checkDestructured to false).

Fixes #530.

@brettz9 brettz9 requested a review from golopot May 11, 2020 07:19
message: 'Missing JSDoc @param "bar" declaration.',
},
{
message: 'Missing JSDoc @param "root0" declaration.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is confusing, what is root0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the feature added in #498 --that when a destructured parameter is also missing its root declaration, that by default, the word "root" will be used followed by a 0-based auto-incrementing number for each subsequent root (one can avoid the numeric additions with specific config, or add additional items to an options array so that until all the items in the array are exhausted, it will cycle through the names, e.g., ["root", "cfg", "config"] will add @param root then @param cfg, then @config0, with the last item auto-incrementing). You could see our discussion about it in the PR for more background.

Copy link
Collaborator Author

@brettz9 brettz9 May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I think it makes sense to use root0 in the fixes, subject to user configuration (disablable by setting enableRootFixer to false), we could give a message like "Missing JSDoc @param destructuring root object declaration". Does that sound better? And I'd be personally ok having enableRootFixer default to false, but sometimes I think it is good when the defaults are--within reason and not genuinely harmful--a little on the aggressive side since it informs users of the features they might not learn about otherwise, and if they don't want it, they can come looking for how to disable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing JSDoc @param declaration for destructured parameter {bar}.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could potentially become quite long though, no? e.g., {bar, baz, foo: {def: {ghi}}, many, others}

Copy link
Collaborator Author

@brettz9 brettz9 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could just slice it to a certain maximum length, adding ellipses as needed, and the curly bracket always at the end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should we differentiate in this test case though?

      code: `
          /**
           *
           */
          function quux ({foo}) {

          }
      `,
      errors: [
        {
          message: 'Missing JSDoc @param "root0" declaration.',
        },
        {
          message: 'Missing JSDoc @param "root0.foo" declaration.',
        },
      ],
      output: `
          /**
           * @param root0
           * @param root0.foo
           */
          function quux ({foo}) {

          }
      `,

Report Missing JSDoc @param "{foo}" declaration twice?

Copy link
Collaborator Author

@brettz9 brettz9 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to report just once because the root object may or may not already be defined, and if not defined, there should continue to be a separate message and fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, if it's ok, can we discuss this as a separate issue for fixing reporting messages? This discussion, though valid, is concerning a preexisting behavior (we refer to root0 in other messages, not just in this PR). It would be nice to get this merged so the disabling functionality is available sooner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as the solution, I guess I can just change it to report:

Missing JSDoc @param "{foo}" declaration
Missing JSDoc @param "foo" in "{foo}" declaration

@brettz9 brettz9 force-pushed the checkDestructured branch 2 times, most recently from 88ebe41 to 01280b4 Compare May 12, 2020 07:04
@brettz9 brettz9 changed the title Check destructured checkDestructured property to disable destructured checks May 12, 2020
@brettz9 brettz9 force-pushed the checkDestructured branch from 01280b4 to 920f2e1 Compare May 12, 2020 14:45
@brettz9 brettz9 force-pushed the checkDestructured branch 2 times, most recently from e7252db to c251641 Compare May 12, 2020 21:20
@brettz9 brettz9 force-pushed the checkDestructured branch from c251641 to bc5614b Compare May 12, 2020 23:16
@brettz9 brettz9 merged commit 4df57a8 into gajus:master May 13, 2020
@brettz9 brettz9 deleted the checkDestructured branch May 13, 2020 01:28
@gajus
Copy link
Owner

gajus commented May 13, 2020

🎉 This PR is included in version 25.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label May 13, 2020
@brettz9 brettz9 mentioned this pull request May 14, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to configure require-param to work identical to pre - v25
3 participants