Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't fail check-param-names on destructuring in arguments - fixes #90 #92

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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: 5 additions & 0 deletions lib/rules/validate-jsdoc/check-param-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function validateCheckParamNames(node, err) {
function(tag, i) {
// checking validity
if (!tag.name) {
// There is no parameter name in destructuring assignments.
if (node.params[i - skipped] && node.params[i - skipped].name === undefined) {
return;
}

return err('Missing param name', tag.loc);
}

Expand Down
57 changes: 57 additions & 0 deletions test/lib/rules/validate-jsdoc/check-param-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,61 @@ describe('lib/rules/validate-jsdoc/check-param-names', function() {

});


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you drop one empty line?

describe('with destructurings', function() {
var checker = global.checker({
plugins: ['./lib/index'],
esnext: true
});
checker.rules({checkParamNames: true});

checker.cases([
/* jshint ignore:start */
// jscs:disable
{
it: 'should not report missing parameter name for object destructurings',
code: [
'/**',
' * @param {object}',
' */',
'function obj({param}) {',
'}'
].join('\n')
}, {
it: 'should not report missing parameter name for object destructurings',
code: [
'/**',
' * @param {object}',
' */',
'function obj({param: newName}) {',
'}'
].join('\n')
}, {
it: 'should not report an error when used next to parameters with properties',
code: [
'/**',
' * @param {object} obj1',
' * @param {string} obj1.property',
' * @param {object}',
' * @param {object} obj2',
' * @param {string} obj2.property',
' */',
'function obj(obj1, {param}, obj2) {',
'}'
].join('\n')
}, {
it: 'should not report missing parameter name for array destructurings',
code: [
'/**',
' * @param {array}',
' */',
'function arr([param]) {',
'}'
].join('\n')
}
// jscs:enable
/* jshint ignore:end */
]);

});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And add one here ;-)