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

Create require-jsdoc rule #1842

Closed
yfr opened this issue Feb 18, 2015 · 18 comments
Closed

Create require-jsdoc rule #1842

yfr opened this issue Feb 18, 2015 · 18 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules

Comments

@yfr
Copy link

yfr commented Feb 18, 2015

I would like to have a requireJsDoc option for valid-jsdoc. Could be false by default but would be nice to enforce jsDoc at all and then of course the correct jsDoc.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@nzakas
Copy link
Member

nzakas commented Feb 18, 2015

Can you please provide more details for what you are proposing? Is not clear from your description.

@nzakas nzakas added the triage An ESLint team member will look at this issue soon label Feb 18, 2015
@yfr
Copy link
Author

yfr commented Feb 18, 2015

Sure!

I want to make sure that every function gets it's jsDoc block. Maybe this would make more sense in it's own rule.

@nzakas
Copy link
Member

nzakas commented Feb 18, 2015

We need to figure out which functions because you may not, for example, want jadoc on an iife or on an anonymous function passed into another function.

We can probably day function declarations should have jsdoc comments. What else?

@yfr
Copy link
Author

yfr commented Feb 18, 2015

Sounds legit. Thought there might be some issues i did not think about.

Maybe we could just start with FunctionDeclaration, FunctionExpression and ArrowFunctionExpression like in valid-jsdoc. These could also be just options.

@nzakas
Copy link
Member

nzakas commented Feb 18, 2015

I don't think those are granular enough. Consider:

function foo() {
   // most likely want to require for this
}

var foo = function() {
    // do we want to require for this? It's a FunctionExpression
};

foo(function() {
    // this is a FunctionExpression, too. 
});

(function() {
    // this is a FunctionExpression, too.
}());

// these?
var foo = () => {};
foo(() => {});

@yfr
Copy link
Author

yfr commented Feb 19, 2015

Ok. I see your point. Is there a way to make more precise decisions? I personally would like the first two to have jsDoc required.

Do you think it's worth building a plugin? Or is this just to special?

@nzakas
Copy link
Member

nzakas commented Feb 20, 2015

We can be more specific, we just have to know what to look for.

I like the idea of a require-jsdoc rule as part of ESLint. Just need to figure out the correct options.

@nzakas nzakas added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Feb 28, 2015
@nzakas nzakas changed the title requireJsDoc option for valid-jsdoc Create require-jsdoc rule Feb 28, 2015
@nzakas nzakas added good first issue Good for people who haven't worked on ESLint before and removed good first issue Good for people who haven't worked on ESLint before labels Mar 28, 2015
@grabbou
Copy link

grabbou commented May 29, 2015

@nzakas what about starting with all prototype methods and class methods in ES6? Once the feature is up & running, we can figure out other places where it should work. If that's something you'd like to see working, can submit the proposal.

@xjamundx
Copy link
Contributor

I think any FunctionDeclaration at the root of a file would be what I'd personally want to see, but I can see how this depends drastically on the project (are you using a lot of prototypes or ES6 classes) and module system being used (that wouldn't work for AMD for example).

We may also talk to @nrsedat about his plugin to see if he has any ideas based on his plugin.
https://github.com/nrsedat/eslint-plugin-require-jsdoc

Some ideas for possible config options we could turn on or off:

  • declarations (i.e. function a() {})
  • es6Classes
  • es6Methods
  • vars
  • methods (meaning { x: function() {} }
  • expressions ( meaning var x = function() {} and even x.prototype.thing = function() {})

@nzakas
Copy link
Member

nzakas commented May 29, 2015

@grabbou we need to stay with something that easily lends itself to extension later, that's the tricky part.

@xjamundx I think the naming is the big problem to solve here. Some of these are pretty ambiguous

@andreas-marschke
Copy link

Hi! I have a PR to run fail eslint on undocumented named functions it's here: #2980

If you'd like to have this issue resolved feel free to comment on the PR.

nzakas added a commit that referenced this issue Sep 1, 2015
New: `require-jsdoc` rule (fixes #1842)
@sebastienbarre
Copy link

Thanks for creating this rule. Was wondering if I'm missing something here. Shouldn't it be triggered for FunctionExpression as well? This, for example, doesn't trigger any error, even though it has no doc block:

var promiseRejectError = function() {
  return Promise.reject(Error('boom'));
};

The source code seems to mention it, but FunctionExpression is not an accepted configuration option.

Thanks

@gyandeeps
Copy link
Member

Yup we do not support FunctionExpression (ref docs).

@sebastienbarre
Copy link

@gyandeeps Thanks. Any particular rationale? I was wondering about the code in the rule:

        "FunctionExpression": function(node) {
            if (options.MethodDefinition) {
                checkClassMethodJsDoc(node);
            }
        },

@JustinLivi
Copy link

Are there any plans to support function expressions? It seems very useful when documenting modules. For example, right now there's no way to consider this a problem:

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

@vobu
Copy link

vobu commented Apr 5, 2016

+1 on this

@platinumazure
Copy link
Member

Please open a new issue if you want an enhancement to this rule. Thanks!

@vobu
Copy link

vobu commented Apr 15, 2016

here it is: #5867

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

10 participants