-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix location issues in jsdoc and split param rules
- create DocLocation class with line and column - add loc field to DocType, DocName and DocTag - split params to several files - add tests for jsdoc classes
- Loading branch information
Alexej Yaroshevich
committed
Nov 10, 2014
1 parent
f74570c
commit a3ecd83
Showing
13 changed files
with
289 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = validateCheckParamNames; | ||
module.exports.scopes = ['function']; | ||
module.exports.options = { | ||
checkParamNames: {allowedValues: [true]} | ||
}; | ||
|
||
/** | ||
* validator for check-param-names | ||
* @param {(FunctionDeclaration|FunctionExpression)} node | ||
* @param {Function} err | ||
*/ | ||
function validateCheckParamNames(node, err) { | ||
node.jsdoc.iterateByType(['param', 'arg', 'argument'], | ||
/** | ||
* tag checker | ||
* @param {DocType} tag | ||
* @param {Number} i index | ||
*/ | ||
function(tag, i) { | ||
var param = node.params[i]; | ||
|
||
// checking validity | ||
if (!tag.name) { | ||
return err('missing param name', tag.loc); | ||
} | ||
|
||
// checking name | ||
if (tag.name.value !== param.name) { | ||
return err('expected ' + param.name + ' but got ' + tag.name.value, | ||
tag.name.loc || node.jsdoc.loc.start); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = validateCheckParamNames; | ||
module.exports.scopes = ['function']; | ||
module.exports.options = { | ||
checkRedundantParams: {allowedValues: [true]} | ||
}; | ||
|
||
/** | ||
* validator for check-param-names | ||
* @param {(FunctionDeclaration|FunctionExpression)} node | ||
* @param {Function} err | ||
*/ | ||
function validateCheckParamNames(node, err) { | ||
node.jsdoc.iterateByType(['param', 'arg', 'argument'], | ||
/** | ||
* tag checker | ||
* @param {DocType} tag | ||
* @param {Number} i index | ||
*/ | ||
function(tag, i) { | ||
// skip if there is dot in param name (object's inner param) | ||
if (tag.name.value.indexOf('.') !== -1) { | ||
return; | ||
} | ||
|
||
var param = node.params[i]; | ||
var _optional = tag.optional || (tag.type && tag.type.optional); | ||
|
||
// checking redundant | ||
if (!_optional && !param) { | ||
return err('redundant param statement'); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = validateParamTag; | ||
module.exports.tags = ['param', 'arg', 'argument']; | ||
module.exports.scopes = ['function']; | ||
module.exports.options = { | ||
requireParamTypes: {allowedValues: [true]} | ||
}; | ||
|
||
/** | ||
* validator for @param | ||
* @param {(FunctionDeclaration|FunctionExpression)} node | ||
* @param {DocTag} tag | ||
* @param {Function} err | ||
*/ | ||
function validateParamTag(node, tag, err) { | ||
// checking existance | ||
if (!tag.type) { | ||
return err('missing param type'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.