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
Emit warnings for missing JSDoc comments #2960
Conversation
Before it was implicit via the WordPress ESLint plugin
Size Change: 0 B Total Size: 1 MB ℹ️ View Unchanged
|
Codecov Report
@@ Coverage Diff @@
## master #2960 +/- ##
===========================================
+ Coverage 28.48% 81.27% +52.79%
===========================================
Files 670 710 +40
Lines 11652 11989 +337
===========================================
+ Hits 3319 9744 +6425
+ Misses 8333 2245 -6088
|
There are 855 problems (0 errors, 855 warnings) in the linter here. Are we going to fix these now? |
@spacedmonkey Where are there errors? I only see warnings, and yes they are meant to be fixed - slowly, in multiple PRs, until there are zero warnings left. |
I meant warning yes. But it mind of breaks github, as it can only highligh changes on 50 lines. Do you think that is a problem? |
Could we generate js docs, in an IDE. Even if they dont have comments? I know phpstorm can generate phpdocs... |
Ah, you mean the limit of 50 annotations per PR? Yeah that might cause more important messages (errors) to be hidden. We could skip warnings from being output on GitHub, no big deal. An alternative would be only enabling these warnings for one area of the code base at the time.
Yes and no. Auto-generated JSDoc annotations are basically like not having any annotations at all. Especially because the IDE can't add type information (because we don't have any types). Also, JSDoc comments become more useful if they have clear descriptions. Auto-generated comments can certainly help initially, but all this can only really be done manually. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice this is suggesting JSDoc comments on every function, even functions that are private to the file, which may be overkill.
I think we should be careful to avoid comments that mostly repeat the code it's trying to document. If the code is self-explanatory and there's really nothing to document about, and a comment is just redundant and adds unnecessary clutter to the code.
go/java-practices/comments#what_for
Good point. Just realized the ESLint plugin supports a
Absolutely. One thing that I want to note is that this change here paves the way for more easily introducing TypeScript in the future. That's because TypeScript can use the JSDoc information for the type checking. So once we have correct types in JSDoc everywhere, switching to TS will be a breeze because we've already dealt with the types. |
Reduces number of warnings from ~800 to ~600
Summary
EmitS warnings for missing JSDoc comments
Relevant Technical Choices
eslint-plugin-jsdoc
usage explicitBefore it was implicit via the WordPress ESLint plugin
This makes it easier to eventually adopt TypeScript (Adopting TypeScript #1715)
To-do
User-facing changes
N/A
Testing Instructions
Run linter
See #1714