valid-jsdoc fails on functions that use ES6 destructuring assignment in signature
See original GitHub issueGiven the following code:
/**
* @param {object} options
* @return {number}
*/
const test = function({ a, b, c }) {
return a + b + c;
};
module.exports = test;
The valid-jsdoc
rule fails with the following message:
Expected JSDoc for ‘undefined’ but found ‘options’. (valid-jsdoc)
Changing the variable name in the @param
tag to “undefined” doesn’t work either.
ESLint 0.17.0
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >Destructuring assignment in function call while preserving the ...
This means that using destructuring with rest parameters - for objects and arrays alike - would not preserve the entire array or object...
Read more >valid-jsdoc - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Destructuring Mixed Objects and Function Arguments in ES6
Learn more ways to destructure mixed objects in and function arguments using JavaScript, HTML, and ES6 in this JS tutorial.
Read more >eslint | Yarn - Package Manager
... 1d443a0 Fix: valid-jsdoc does not know async function returns (fixes #9881) ... 075ec25 Chore: update to use ES6 classes (refs #7849) (#7891)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems like this is a good behavior. Using destructuring in a method or function signature seems like a poor contract to make.
I would suggest that it is a good practice to have all required items listed separately in the method signature and use a single parameter for a config object.
Within the function body, it makes sense to use destructuring to pull out distinct properties from the provided config/options object. And it would make sense to use destructing when calling the method. But I don’t think destructing belongs in the method signature itself.
@nzakas, The fix in a1da3b4 sort of dodges the issue a bit, and doesn’t quite do what we’d hope it could…
It turns out JSDoc does support destructing via making up a placeholder name. It is lacking in official documentation. https://github.com/jsdoc3/jsdoc/issues/987
Perhaps, we can support this kind of grammar?