UNPKG

canonical

Version:

Canonical code style linter and formatter for JavaScript, SCSS and CSS.

33 lines (28 loc) 769 B
module.exports = checkReturnTypes; module.exports.tags = ['return', 'returns']; module.exports.scopes = ['function']; module.exports.options = { checkRedundantReturns: {allowedValues: [true]} }; /** * Checking returns types * * @param {(FunctionDeclaration|FunctionExpression)} node * @param {DocTag} tag * @param {Function} err */ function checkReturnTypes(node, tag, err) { // checking consistency if (!tag.type) { return; } // skip abstract methods if (node.jsdoc.abstract) { return; } // checking redundant: invalid or not return statements in code var redundant = !Boolean(this._getReturnStatementsForNode(node).length); if (redundant) { err('Redundant return statement', tag.loc); } }