Skip to content

Commit c8d0611

Browse files
brettz9l1bbcsg
authored andcommitted
fix(require-param): skip destructuring; fixes gajus#352 (though still need to handle gajus#11 )
1 parent ea3e057 commit c8d0611

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6237,6 +6237,17 @@ export class SomeClass {
62376237
*/
62386238
constructor(private property: string) {}
62396239
}
6240+
6241+
/**
6242+
* Assign the project to an employee.
6243+
*
6244+
* @param {object} employee - The employee who is responsible for the project.
6245+
* @param {string} employee.name - The name of the employee.
6246+
* @param {string} employee.department - The employee's department.
6247+
*/
6248+
function assign({name, department}) {
6249+
// ...
6250+
}
62406251
````
62416252

62426253

src/rules/requireParam.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export default iterateJsdoc(({
2121
}
2222

2323
functionParameterNames.forEach((functionParameterName) => {
24+
if (['<ObjectPattern>', '<ArrayPattern>'].includes(functionParameterName)) {
25+
return;
26+
}
2427
if (!jsdocParameterNames.includes(functionParameterName)) {
2528
report(`Missing JSDoc @${utils.getPreferredTagName({tagName: 'param'})} "${functionParameterName}" declaration.`);
2629
}

test/rules/assertions/requireParam.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,20 @@ export default {
788788
parserOptions: {
789789
sourceType: 'module'
790790
}
791+
},
792+
{
793+
code: `
794+
/**
795+
* Assign the project to an employee.
796+
*
797+
* @param {object} employee - The employee who is responsible for the project.
798+
* @param {string} employee.name - The name of the employee.
799+
* @param {string} employee.department - The employee's department.
800+
*/
801+
function assign({name, department}) {
802+
// ...
803+
}
804+
`
791805
}
792806
]
793807
};

0 commit comments

Comments
 (0)