File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ module . exports = checkReturnTypes ;
2+ module . exports . tags = [ 'return' , 'returns' ] ;
3+ module . exports . scopes = [ 'function' ] ;
4+ module . exports . options = {
5+ checkRedundantReturns : { allowedValues : [ true ] }
6+ } ;
7+
8+ /**
9+ * checking returns types
10+ * @param {(FunctionDeclaration|FunctionExpression) } node
11+ * @param {DocTag } tag
12+ * @param {Function } err
13+ */
14+ function checkReturnTypes ( node , tag , err ) {
15+ // checking consistency
16+ if ( ! tag . type ) {
17+ return ;
18+ }
19+
20+ // checking redundant: invalid or not return statements in code
21+ var redundant = ! tag . type . valid || ! this . _getReturnStatementsForNode ( node ) . length ;
22+
23+ if ( redundant ) {
24+ err ( 'redundant returns statement' ) ;
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -12,16 +12,15 @@ module.exports.options = {
1212 * @param {Function } err
1313 */
1414function checkReturnTypes ( node , tag , err ) {
15- /* var option = this._options.checkReturnTypes;
16- if (!node.jsdoc ) {
15+ // try to check returns types
16+ if ( ! tag . type || ! tag . type . valid ) {
1717 return ;
1818 }
1919
20- console.log(node.jsdoc);
21-
22- if (node.jsdoc) {
23-
24- }*/
25- if ( node ) { err ( ) ; }
26- return tag ;
20+ var returnsArgumentStatements = this . _getReturnStatementsForNode ( node ) ;
21+ returnsArgumentStatements . forEach ( function ( argument ) {
22+ if ( ! tag . type . match ( argument ) ) {
23+ err ( 'Wrong returns value' , argument . loc . start ) ;
24+ }
25+ } ) ;
2726}
Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ var validatorsByName = module.exports = {
77 checkRedundantParams : require ( './check-redundant-params' ) ,
88 requireParamTypes : require ( './require-param-types' ) ,
99
10- returns : require ( './returns' ) ,
10+ checkReturnTypes : require ( './check-return-types' ) ,
11+ requireReturnTypes : require ( './require-return-types' ) ,
12+ checkRedundantReturns : require ( './check-redundant-returns' ) ,
13+
14+ //returns: require('./returns'),
1115 checkRedundantAccess : require ( './check-redundant-access' ) ,
1216 enforceExistence : require ( './enforce-existence' ) ,
1317 leadingUnderscoreAccess : require ( './leading-underscore-access' )
Original file line number Diff line number Diff line change 1+ module . exports = requireReturnTypes ;
2+ module . exports . tags = [ 'return' , 'returns' ] ;
3+ module . exports . scopes = [ 'function' ] ;
4+ module . exports . options = {
5+ requireReturnTypes : { allowedValues : [ true ] }
6+ } ;
7+
8+ /**
9+ * requiring returns types (?)
10+ * @param {(FunctionDeclaration|FunctionExpression) } node
11+ * @param {DocTag } tag
12+ * @param {Function } err
13+ */
14+ function requireReturnTypes ( node , tag , err ) {
15+ if ( ! tag . type ) {
16+ err ( 'Missing type in @returns statement' ) ;
17+ }
18+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments