Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions closure_linter/error_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ def HandleError(self, error):
self._DeleteToken(token)
self._AddFix(token)

elif code == errors.INVALID_JSDOC_TAG:
if token.string == '@returns':
token.string = '@return'
self._AddFix(token)

elif code == errors.FILE_MISSING_NEWLINE:
# This error is fixed implicitly by the way we restore the file
self._AddFix(token)
Expand Down
6 changes: 3 additions & 3 deletions closure_linter/javascriptlintrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def CheckToken(self, token, state):
if not self._limited_doc_checks:
if (function.has_return and function.doc and
not is_immediately_called and
not function.doc.HasFlag('return') and
not (function.doc.HasFlag('returns') or function.doc.HasFlag('return')) and
not function.doc.InheritsDocumentation() and
not function.doc.HasFlag('constructor')):
# Check for proper documentation of return value.
Expand All @@ -287,9 +287,9 @@ def CheckToken(self, token, state):
elif (not function.has_return and
not function.has_throw and
function.doc and
function.doc.HasFlag('return') and
(function.doc.HasFlag('returns') or function.doc.HasFlag('return')) and
not state.InInterfaceMethod()):
flag = function.doc.GetFlag('return')
flag = function.doc.GetFlag('returns') or function.doc.GetFlag('return')
valid_no_return_names = ['undefined', 'void', '*']
invalid_return = flag.jstype is None or not any(
sub_type.identifier in valid_no_return_names
Expand Down
1 change: 1 addition & 0 deletions closure_linter/statetracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class DocFlag(object):
'protected',
'public',
'return',
'returns',
'see',
'stableIdGenerator',
'struct',
Expand Down
45 changes: 44 additions & 1 deletion closure_linter/testdata/jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ goog.require('goog.math.Vec2');


/**
* @returns // INVALID_JSDOC_TAG
* @params // INVALID_JSDOC_TAG
* @defines // INVALID_JSDOC_TAG
* @nginject // INVALID_JSDOC_TAG
Expand Down Expand Up @@ -169,6 +168,14 @@ function goodReturn() {
}


/**
* @returns {boolean} A boolean primitive.
*/
function goodReturns() {
return something;
}


/**
* @return {some.long.type.that.will.make.the.description.start.on.next.line}
* An object.
Expand All @@ -178,6 +185,15 @@ function anotherGoodReturn() {
}


/**
* @returns {some.long.type.that.will.make.the.description.start.on.next.line}
* An object.
*/
function anotherGoodReturns() {
return something;
}


// +2: MISSING_JSDOC_TAG_TYPE
/**
* @return false.
Expand All @@ -187,6 +203,15 @@ function missingReturnType() {
}


// +2: MISSING_JSDOC_TAG_TYPE
/**
* @returns false.
*/
function missingReturnsType() {
return something;
}


// +2: MISSING_SPACE
/**
* @return{type}
Expand All @@ -196,6 +221,15 @@ function missingSpaceOnReturnType() {
}


// +2: MISSING_SPACE
/**
* @returns{type}
*/
function missingSpaceOnReturnsType() {
return something;
}


// +2: MISSING_JSDOC_TAG_TYPE
/**
* @return
Expand All @@ -204,6 +238,15 @@ function missingReturnType() {
return something;
}


// +2: MISSING_JSDOC_TAG_TYPE
/**
* @returns
*/
function missingReturnsType() {
return something;
}

class.missingDocs = function() { // MISSING_MEMBER_DOCUMENTATION
};

Expand Down