catapult-project / catapult

Deprecated Catapult GitHub. Please instead use http://crbug.com "Speed>Benchmarks" component for bugs and https://chromium.googlesource.com/catapult for downloading and editing source code..
https://chromium.googlesource.com/catapult
BSD 3-Clause "New" or "Revised" License
1.93k stars 563 forks source link

Intent to turn on JSDoc check in ESLint #3239

Open lpy opened 7 years ago

lpy commented 7 years ago

Tl;dr JSDoc check in eslint will be turnt on by default.

Rules Summary

Explicitly require that

Explicitly not require that

eslint rule

"valid-jsdoc": [
  "error", {
    "requireReturn": false,
    "requireReturnType": true,
    "requireParamDescription": false,
    "requireReturnDescription": true
  }
],

There is a bunch of violation in catapult codebase right now, I put them in a spreasheet

How you can help as an owner/reviewer

What you should do as a contributor

lpy commented 7 years ago

@benshayden @eakuefner @fmeawad @tdresser @zeptonaut @anniesullie

tdresser commented 7 years ago

From: dashboard/dashboard/elements/alert-remove-box.html, with that rule applied:

/usr/local/google/home/tdresser/chromium/src/third_party/catapult/dashboard/dashboard/elements/alert-remove-box.html
  48:7  error  Missing JSDoc for parameter 'event'   valid-jsdoc
  48:7  error  Missing JSDoc for parameter 'detail'  valid-jsdoc

Aren't we trying to not require that every parameter be annotated? "requireParamDescription": false, only makes it so you don't need a description as part of your @param annotation. You still need the annotation itself...

tdresser commented 7 years ago

As one data point, in tracing/tracing/metrics, we have

lpy commented 7 years ago

mmmm, I thought we were saying we wouldn't require description for every param but still need you to annotate it. @eakuefner could you clarify it? I didn't find a configuration that would allow us to skip params.

tdresser commented 7 years ago

I agree that there's no config option that would let us skip params.

eakuefner commented 7 years ago

What we came to in the meeting was that people shouldn't be required to specify params, but yes, as folks are saying, there does not seem to be an option for disable param checking entirely. We have two options here:

  1. Back off on making params optional, and just say that if you do write a JSDoc comment you have to specify params, or
  2. File an eslint bug/modify the rule to add a true-by-default requireParams option that, if false, disables param checking.
lpy commented 7 years ago

Let the first option becomes our workaround, and the second option should be the right way, I will file a bug on eslint.

lpy commented 7 years ago

It turns out there's already a feature request that got closed because they claimed they couldn't reach consensus. I am trying to see if we can reopen it.

zeptonaut commented 7 years ago

@lpy I'm pretty sure that the comment that alberto made on the thread you linked to was automatically added after a long period of no discussion on the thread: I've seen the same message posted on other bug threads. I think it's very likely that, if we were to open a bug describing exactly the feature that we'd like to support, link to the old bug that didn't reach consensus, and make it clear that we were willing to write the pull request required to add the feature, the eslint folks would probably be receptive.

lpy commented 7 years ago

feature request submitted.

zeptonaut commented 7 years ago

@lpy, it's probably worth mentioning in the feature request not just what we'd like changed but also why we feel that it's a valid way to use jsdoc.

I think one thing that's important to convey is for a function like:

/**

We don't think that it adds anything to the jsdoc by adding an @param for iterable. Especially given the fact that we're not parsing the jsdocs to build documentation online, but rather using them to help increase readability int he code, we feel that adding parameter descriptions where they're not necessary actually hurts readability.