Opened 5 weeks ago
Last modified 2 weeks ago
#66033 new task (blessed)
JSDocs improvements for 7.2
| Reported by: | afercia | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | javascript, docs, coding-standards |
Description
This ticket is for various issues and improvements to the JavaScript inline documentation surfaced via JSDocs.
JSDocs has been restored to a working configuration in #65939. So far, the configuration is a minimal one and only checks for a few rules. The plan is to progressively extend the rules in the configuration ans fix the newly reported issues.
This task originates from the JavaScript Inline Docs Initiative which is a much needed long-term project. The effort started in the initiative has somehow stalled across the years. Now, JSDocs provides a convenient tool to revive the initiative and complete the task.
Suggested workflow for anyone willing to contribute to this effort:
Recommended rules to start with, in this order:
jsdoc/require-descriptionjsdoc/require-returnsjsdoc/require-returns-typejsdoc/require-returns-descriptionjsdoc/require-jsdoc
- Temporarily add
'jsdoc/require-description': 'error',to the configuration. - Fix the issues, in this case by adding the reported missing descriptions.
- Avoid to submit a patch / PR that touches too many files at the same time. Prefer splitting into separate patches / PRs with a reasonable size, at your judgment.
- Verify there are no pending patches / PRs that already fix those files.
- Do not commit the added rule in the configuration.
- Once all the reported issues are fixed, the new rule can be added and committed.
- Repeat the cycle with a new rule.
Cc @westonruter
Change History (47)
This ticket was mentioned in PR #13421 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#7
- Keywords has-patch added
See https://core.trac.wordpress.org/ticket/66033
In preparation of the introduction of the rule jsdoc/require-description for JSDoc, this PR adds several missing descriptions to JS functions in the enqueues directory. Leaves out:
- All the Customize related files.
- All the Media related files.
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Haiku 4.5
Used for: Quickly drafting some descriptions.
@afercia commented on PR #13421:
4 weeks ago
#9
Committed in https://core.trac.wordpress.org/changeset/63514
This ticket was mentioned in PR #13423 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#10
See https://core.trac.wordpress.org/ticket/66033
In preparation of the introduction of the rule jsdoc/require-description for JSDoc, this PR adds several missing descriptions to JS functions in the media directory.
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Haiku 4.5
Used for: Quickly drafting some descriptions.
This ticket was mentioned in PR #13424 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#12
See https://core.trac.wordpress.org/ticket/66033
In preparation of the introduction of the rule jsdoc/require-description for JSDoc, this PR adds several missing descriptions to the Customize JS functions.
Also, enables the jsdoc/require-description JSDoc rule.
- Run
npm run lint:jsdocand observe there are no reported errors. - Check the added descriptions are meaningful.
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Haiku 4.5
Used for: Quickly drafting some descriptions.
@afercia commented on PR #13423:
4 weeks ago
#13
Committed in https://core.trac.wordpress.org/changeset/63516
@westonruter commented on PR #13424:
4 weeks ago
#14
See also the post-commit suggestions I l just left in https://github.com/WordPress/wordpress-develop/pull/13423
This ticket was mentioned in PR #13426 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#15
Minor JSDocs fixes after CR on https://github.com/WordPress/wordpress-develop/pull/13423
See https://core.trac.wordpress.org/ticket/66033
## Use of AI Tools
None
@afercia commented on PR #13426:
4 weeks ago
#17
Committed in https://core.trac.wordpress.org/changeset/63521
@afercia commented on PR #13424:
4 weeks ago
#19
Committed in https://core.trac.wordpress.org/changeset/63525
This ticket was mentioned in PR #13439 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#20
See https://core.trac.wordpress.org/ticket/66033
- Enables the
jsdoc/require-jsdocJSDoc rule. - Fixes all the reported 73 violations of missing docblocks.
Run npm run lint:jsdoc and observe there are no reported violations.
To evaluate for the future:
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#require
By default, the jsdoc/require-jsdoc options > require setting enables this check only for FunctionDeclaration.
When enabling all the other options (see below) ~900 additional violations are reported:
'jsdoc/require-jsdoc': [ 'error', {
require: {
FunctionDeclaration: true,
ArrowFunctionExpression: true, // false by default
ClassDeclaration: true, // false by default
ClassExpression: true, // false by default
FunctionExpression: true, // false by default
MethodDefinition: true, // false by default
},
} ],
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Haiku 4.5
Used for: Quickly drafting some descriptions.
@afercia commented on PR #13439:
4 weeks ago
#23
Committed in https://core.trac.wordpress.org/changeset/63556
#24
@
4 weeks ago
Next JSDoc rules worth considering to be added:
Functional:
'jsdoc/require-param-description': 'error', 'jsdoc/require-param-name': 'error', 'jsdoc/valid-types': 'error',
Indentation / alignments / formatting:
'jsdoc/require-hyphen-before-param-description': [ 'error', 'never' ],
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/check-line-alignment': [ 'error', 'always', {
tags: [ 'param', 'arg', 'argument', 'property', 'prop', 'template' ],
} ],
This ticket was mentioned in PR #13473 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#25
See https://core.trac.wordpress.org/ticket/66033
- Enables the
jsdoc/require-param-nameJSDoc rule. - Sorts rules alphabetically.
## Use of AI Tools
@afercia commented on PR #13473:
4 weeks ago
#27
Committed in https://core.trac.wordpress.org/changeset/63577
This ticket was mentioned in PR #13475 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#28
See https://core.trac.wordpress.org/ticket/66033
- Enables the JSDoc rule
require-param-description. - Fixes all the reported violations.
Run npm run lint:jsdoc and observe there are no reported violations.
## Use of AI Tools
@afercia commented on PR #13475:
4 weeks ago
#30
Committed in https://core.trac.wordpress.org/changeset/63598
This ticket was mentioned in PR #13486 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#31
See https://core.trac.wordpress.org/ticket/66033
- Enables the JSDoc rule
jsdoc/valid-types. - Todo: Fixes all the reported violations.
There are 69 violations of the valid-types rule. @westonruter since you are the _types master_, would you like to take care of this fix? Just run npm run lint:jsdoc and fix all the reported violations.
## Use of AI Tools
This ticket was mentioned in PR #13490 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#32
See https://core.trac.wordpress.org/ticket/66033
- Enables the following JSDoc rules:
jsdoc/check-alignmentjsdoc/check-indentationjsdoc/check-line-alignmentjsdoc/require-hyphen-before-param-description-> never
- Fixes all the violations.
This is a purely formatting fix.
## Use of AI Tools
#33
@
4 weeks ago
I'm wondering whether the docblocks of the JS files within the tools directory should be linted as well.
@afercia commented on PR #13490:
4 weeks ago
#35
Committed in https://core.trac.wordpress.org/changeset/63600
@afercia commented on PR #13486:
2 weeks ago
#37
Committed in https://core.trac.wordpress.org/changeset/63766
This ticket was mentioned in PR #13632 on WordPress/wordpress-develop by @afercia.
2 weeks ago
#38
See https://core.trac.wordpress.org/ticket/66033
Enables the following JSDoc rules:
jsdoc/check-property-namesjsdoc/require-propertyjsdoc/require-property-namejsdoc/require-property-descriptionjsdoc/require-property-type
Fixes all the related violations.
Use of AI Tools
This ticket was mentioned in PR #13634 on WordPress/wordpress-develop by @afercia.
2 weeks ago
#39
See https://core.trac.wordpress.org/ticket/66033
Enables the following JSDoc rules:
jsdoc/no-blank-blocksjsdoc/no-blank-block-descriptions
No current violations to fix.
Use of AI Tools
@afercia commented on PR #13634:
2 weeks ago
#41
Committed in https://core.trac.wordpress.org/changeset/63769
@afercia commented on PR #13632:
2 weeks ago
#43
Committed in https://core.trac.wordpress.org/changeset/63775
#44
@
2 weeks ago
Overall, the work done so far has greatly improved the JavaScript inline documentation. Most importantly, there is now a working tool integrated in the CI that checks for the documentation coding standards.
Also, any modern IDE can take advantage by the updated JSDoc config as the IDE autocomplete will understand how to suggest meaningful docblocks. Not to mention that indentation and alignments will be fixed automatically when saving.
Next steps I'd recommend:
1
Upgrade the eslint-plugin-jsdoc version to latest. This is strongly recommended as the new version will likely report new violations that should be fixed before any other change. The related issue in the Gutenberg repository should be prioritized. See https://github.com/WordPress/gutenberg/issues/82726
2
After that, start expanding some of the most important rules. For example the require-jsdoc rule has a require option that defaults to true only for FunctionDeclaration. Expanding true to the following should be considered soon:
- ArrowFunctionExpression
- ClassDeclaration
- ClassExpression
- FunctionExpression
- MethodDefinition
This ticket was mentioned in PR #13650 on WordPress/wordpress-develop by @afercia.
2 weeks ago
#45
Follow-up to https://github.com/WordPress/wordpress-develop/pull/13486
See https://core.trac.wordpress.org/ticket/66033
Use of AI Tools
@afercia commented on PR #13650:
2 weeks ago
#47
Committed in https://core.trac.wordpress.org/changeset/63791
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In 63454: