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

Docstrings for package json helpers #8373

Merged
merged 4 commits into from
Sep 6, 2022
Merged

Docstrings for package json helpers #8373

merged 4 commits into from
Sep 6, 2022

Conversation

pr7prashant
Copy link
Contributor

  • Added docstrings for package json helpers

@shields-ci
Copy link

shields-ci commented Sep 3, 2022

Messages
📖 ✨ Thanks for your contribution to Shields, @pr7prashant!

Generated by 🚫 dangerJS against 2351e55

@calebcartwright calebcartwright added the documentation Developer and end-user documentation label Sep 3, 2022
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

thanks for continuing to work on these

* Checks if the object has all the dependency types and the dependency types are valid.
*
* @type {object}
*/
Copy link
Member

Choose a reason for hiding this comment

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

Because Joi schemas are so commonly used, we've actually set up jsdoc so that we can use Joi as a "type" for schemas

shields/.eslintrc.yml

Lines 170 to 171 in daca767

# allow Joi as an undefined type
jsdoc/no-undefined-types: ['error', { definedTypes: ['Joi'] }]

e.g:

* @param {Joi} attrs.schema Joi schema to validate the response against

I guess we've probably merged a few of these PRs describing the schemas as object but it lets use @type {Joi} for Joi schemas moving forwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted. Joi type does make more sense here. Will remember this moving forward.

* @param {object} attrs.optionalDependencies - Map of optional dependencies
* @throws {string} - Error message if unknown dependency type provided
* @throws {InvalidParameter} - Error if wanted dependency is not present
* @returns {object} Object containing wanted dependency version
Copy link
Member

@chris48s chris48s Sep 4, 2022

Choose a reason for hiding this comment

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

This function does currently return an object, but it doesn't really need to. I expect this is an artefact of some past refactoring. A nice cleanup we could do here would be to update this so it just returns a string and update the handful of places it is called accordingly. Also, the return value (range) might be an exact version, but it might also be a semver range i.e: this value could be something like "~2.1.6" or ">=3.0.0,<4.0.0" rather than a precise version number so lets explain that in the docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will update this description. I'll raise a new PR for the cleanup to keep it simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Developer and end-user documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants