question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enhance require-jsdoc to recognize function expressions

See original GitHub issue

ESLint-version: 1.10.3, default parser

configuration:

"require-jsdoc":
                [
                        2,
                        {
                                "require":
                                {
                                        "FunctionDeclaration": true,
                                        "MethodDefinition": false,
                                        "ClassDeclaration": false
                                }
                        }
                ],

Running eslint (from a grunt task), I would expect this to cause an error:

module.exports.foo = function foo() {
    return 'bar';
}

Instead, it passes through fine.

So that’s why I would propose an enhancement to the require-jsdoc rule to also recognise missing JSDoc blocks in functional expressions such as the above.

All of the below should pass through fine:

/**
* some description
* 
* @returns {string}
*/
module.exports.foo = function foo() {
    return 'bar';
}
/**
 * some description
 *
 * @returns {string}
 */
foo: function() {
    return 'bar';
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:23 (18 by maintainers)

github_iconTop GitHub Comments

4reactions
mightypenguincommented, Aug 24, 2016

Pinging this so people know there is still interest. This would bring my documentation to 90+%.

All I care about is: A) var myfunc = function() {}

B) var object = { myfunc: function() {} }

3reactions
sunjaycommented, Sep 27, 2016

The code I would like this to work for looks like this:

const Actions = {
  actions: new Set(),
  register(name) {
    ...
  },
};

Similar to what everyone else is presenting except instead of register: function(name) { I’m using register(name) { which is allowed in ES6.

Read more comments on GitHub >

github_iconTop Results From Across the Web

require-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 >
JSDoc for reused Function interface - javascript - Stack Overflow
This is the solution I like best thus far as it allows you to use the appropriate variable declaration keyword. The only downside...
Read more >
JSDoc Reference - TypeScript: Documentation
The list below outlines which constructs are currently supported when using JSDoc annotations to provide type information in JavaScript files.
Read more >
Downport "Replace deprecated `require-jsdoc`, `valid-jsdoc ...
"jsdoc/check-param-names": 0, ... "jsdoc/require-description-complete-sentence": 0, ... Convert parent indexes from patch range expressions to numbers.
Read more >
JSDoc typings: all the benefits of TypeScript, with none of the ...
Better than before, because we know that the first parameter needs to be an object, and the second one a mapping function. But...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found