segmentio / eslint-config

Segment's ESLint configurations.
9 stars 6 forks source link

Warn on missing JSDoc comment #30

Open ndhoule opened 8 years ago

ndhoule commented 8 years ago

We should be prepared to fix a lot of stuff when we merge this. JSDoc comments are only valid if they are immediately above the function body (no newline between them), so we're going to need to eliminate the newline everywhere.

ndhoule commented 8 years ago

cc @dominicbarnes

dominicbarnes commented 8 years ago

+1 (glad you chose the warning here too)

stephenmathieson commented 8 years ago

does this require comments on private functions too?

/**
 * Do the stuff with the things.
 * 
 * @param {Array} things
 * @return {Whatever}
 */

function stuff(things) {
  return whatever(things, 42)

  // requiring jsdoc here seems unnecessary imo
  function whatever(a, b) {
    // ...
  }
}
dominicbarnes commented 8 years ago

@stephenmathieson if I'm not mistaken, then yes. I don't know if there's a config to turn that off for "nested" functions, since using closures is a common pattern for getting privacy in non-CommonJS envs.

yields commented 8 years ago

Just curios, since newline between the function and the comment seems to be our "style", why not add a new rule instead of adhering to a rule that goes against our own style?

stephenmathieson commented 8 years ago

@yields that makes much more sense imo

dominicbarnes commented 8 years ago

This is a known/intentional limitation within ESLint I'm afraid, see eslint/eslint#2108. Basically, the extra line-break makes it ambiguous as JSDoc comments may apply to a file instead of a function.