-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Docstrings for package json helpers #8373
Conversation
pr7prashant
commented
Sep 3, 2022
- Added docstrings for package json helpers
|
There was a problem hiding this 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} | ||
*/ |
There was a problem hiding this comment.
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
Lines 170 to 171 in daca767
# allow Joi as an undefined type | |
jsdoc/no-undefined-types: ['error', { definedTypes: ['Joi'] }] |
e.g:
shields/core/base-service/base-json.js
Line 29 in daca767
* @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.
There was a problem hiding this comment.
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.
services/package-json-helpers.js
Outdated
* @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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.