-
Notifications
You must be signed in to change notification settings - Fork 35
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
Question : How to add custom code to check to jscs-jsdoc module? #196
Comments
Heya. Thanks for a question. I don't know much about jsdoc3.4 plugin structures to answer it correctly, but if I got it right the answer is no, jscs-jsdoc doesn't have their own plugin method, but you can base your own rules with jscs-jsdoc's. So I guess you can copy-paste just the p.s. To have 2 |
HI @zxqfox, first i would like to thank you for the quick reply. what i was thinking is i could load the 'scs-jsdoc plugin first then i will create my own jscs plugin that will override your check-return-type behavior but i don't think this is possible ( the error will be already raise) basically the jsdoc plugin structure allow your to register function during the jsdoc process. jsdoc @return is kind of messy when you need to expose a nested object structure /**
* get properties
* @return {object} value
* @return {number} value.id
* @return {string} value.description
*/ with regards, |
I guess we can allow this behaviour with an option since it looks valid and non-conflictable. Do you mind about PR? ;-) The problem with To override you could have to incapsulate jscs-jsdoc (instead of forking), redefine just needed parts like validate-jsdoc.js and check-return-types.js, and export the new ones with the same API. |
well my commits is a pseudo fix, i don't think this is the best approach but it doing the trick. here is the code: module.exports = checkReturnTypes;
module.exports.tags = ['return', 'returns'];
module.exports.scopes = ['function'];
module.exports.options = {
checkReturnTypes: {allowedValues: [true]}
};
/**
* Checking returns types
*
* @param {(FunctionDeclaration|FunctionExpression)} node
* @param {DocTag} tag
* @param {Function} err
*/
function checkReturnTypes(node, tag, err) {
// try to check returns types
if (!tag.type || !tag.type.valid) {
return;
}
var returnsArgumentStatements = this._getReturnStatementsForNode(node);
returnsArgumentStatements.forEach(function(argument) {
if (tag.value && tag.value.indexOf('.') > -1) { // <<<<< add support for nested @returns description
return;
}
if (!tag.type.match(argument)) {
err('Wrong returns value' , argument.loc.start);
}
});
} with regards, |
Hi,
i have a specific rule that allow us to use multiple "@returns" tags in our documentation.
i have modified the check-return-type.js file in order to take this in consideration.
My question is how could i integrate it in my project?
is there a plugin structure like jsdoc3.4 to override a part of the code ? or should i copy the entire jscs-jsdoc in my project ?
with regards,
The text was updated successfully, but these errors were encountered: