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.

Proposal: JSDoc only on exported nodes

See original GitHub issue

What rule do you want to change?

require-jsdoc - link

Support making a rule so that the ESLinters for JSDocs are only applied on items which are going to leave the current source file ( and thus would be visible outside of the current scope. )

Does this change cause the rule to produce more or fewer warnings?

It would add an option to produce fewer warnings.

How will the change be implemented? (New option, new default behavior, etc.)?

There could be a scope attribute to require-jsdoc which allows you to define whether to apply the rules to all nodes. Or to only ones which will be available outside of it’s file.

{
    "require-jsdoc": ["error", {
       "scope": "all" || "exported",
        "require": {
            "FunctionDeclaration": true,
            "MethodDefinition": false,
            "ClassDeclaration": false,
            "ArrowFunctionExpression": false
        }
    }]
}

Please provide some example code that this change will affect:

for Modern: import/export

export class MyThing {}
export function simpleFunction(one, two) {}

For the require style, something like this

module.exports = class Runner extends EventEmitter {}

module.exports.jestChildProcessWithArgs = (workspace: ProjectWorkspace, args: Array<string>): ChildProcess => {}

So for some example code:


var foo = (test) => {
    return test + 10;
}

/**
 * It returns 10
 */
export class Test{
    /**
    * returns the date
    */
    getDate(){}
}

What does the rule currently do for this code?

At the moment all JSDoc checks are applied wholesale throughout your source code. Meaning even internal functions, or test helper functions require comprehensive comments. So this would raise errors for foo but not test.

What will the rule do after it’s changed?

With the scope as exported then the code above would not produce any errors.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Jan 4, 2017

Okay, I’ll champion - I think this is a nice addition.

@orta feel free to submit a PR.

1reaction
nzakascommented, Jan 3, 2017

@byk please add your 👍 to the issue description so we can keep track.

For “scope” we could make it “exportedOnly” to change it into a Boolean option. We probably don’t need a string unless we think there might be a third option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to jsDoc node module.exports object methods in Intellij?
exports = { nameToUpperCase: nameToUpperCase };. I also checked out the jsdocs, but it seems that the only example is to do: 'use...
Read more >
Use JSDoc: @exports
Identify the member that is exported by a JavaScript module. ... JSDoc automatically recognizes the special "module.exports" property in Node.js modules.
Read more >
Google JavaScript Style Guide
Classes, enums, functions, constants, and other symbols are exported using the exports object. Exported symbols may be defined directly on the exports object, ......
Read more >
@es-joy/jsdoccomment | Yarn - Package Manager
This project aims to preserve and expand upon the SourceCode#getJSDocComment functionality of the deprecated ESLint method. It also exports a number of ...
Read more >
eslint-plugin-jsdoc - npm
The defaults in eslint-plugin-jsdoc (for tags which offer ... ancestorsOnly - Only check node ancestors to check if node is exported ...
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