File tree Expand file tree Collapse file tree 5 files changed +57
-67
lines changed Expand file tree Collapse file tree 5 files changed +57
-67
lines changed 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 = {
12
12
* @param {Function } err
13
13
*/
14
14
function 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 ) {
17
17
return ;
18
18
}
19
19
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
+ } ) ;
27
26
}
Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ var validatorsByName = module.exports = {
7
7
checkRedundantParams : require ( './check-redundant-params' ) ,
8
8
requireParamTypes : require ( './require-param-types' ) ,
9
9
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'),
11
15
checkRedundantAccess : require ( './check-redundant-access' ) ,
12
16
enforceExistence : require ( './enforce-existence' ) ,
13
17
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