#43828 closed task (blessed) (fixed)
Add JSDoc ESLint script
Reported by: | netweb | Owned by: | netweb |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch needs-testing |
Focuses: | javascript | Cc: |
Description
This script seeks to add a JSDoc focused ESLint script to check the JSDocs conformity with the WordPress JavaScript Docs Coding Standards
It will also greatly aid those involved with the JavaScript Inline Docs Initiative to ensure patches are conforming to the coding standards.
To test and use this npm script run, npm install
and then npm run lint:jsdoc
in the terminal console.
A sister pull request add similar functionality has been in ongoing development in the Gutenberg repo:
The patch for this ticket adds the ESLint JSDoc configuration to a file named .eslintrc-jsdoc.js
, this is to avoid conflicts with the work in progress of adding ESLint in #31823
Attachments (7)
Change History (33)
#2
@
6 years ago
- Keywords needs-testing added
This patch will need a little more testing to ensure I've excluded, and not errantly omitted any files or folders that we should be checking.
Great idea for @since
, I'll take a look around and see what options are available to check that it exists and ensure that it is valid syntax
This ticket was mentioned in Slack in #core-js by kamataryo. View the logs.
5 years ago
#7
@
5 years ago
Probably we should refresh the patch with [@wordpress/scripts
](https://github.com/WordPress/gutenberg/tree/master/packages/scripts), which includes wp-scripts lint-js
.
#8
@
5 years ago
Sorry to upload 43828.2.diff
which is broken and not svn diff
.
43828.3.diff
should be the minimum required one.
#9
@
5 years ago
The patch 43828.3.diff
includes:
- inherit
.eslintignore
from the existing43828.diff
patch and match it current status - inherit
.eslingrc.js
from the existing43828.diff
patch package.json
update to set@wordpress/scripts
as a dependency- Also npm scripts
npm run lint:js
is added to run it
#10
@
5 years ago
Thanks @kamataryo, sorry I've not replied sooner, I'll take a look at the latest 43828.3.diff patch shortly
#11
@
5 years ago
- Milestone changed from 5.3 to 5.4
Punting this to 5.4 to help clear the 5.3 milestone
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
5 years ago
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
#14
@
5 years ago
- Milestone changed from 5.4 to 5.5
Punting this to 5.5 to help clear the 5.4 milestone
#16
@
4 years ago
Thanks @whyisjake, might me worth trying this config, though it may have a little too much “Gutenberg” based config
https://github.com/WordPress/gutenberg/blob/master/packages/eslint-plugin/configs/jsdoc.js
Either or though, no strong opinion so feel free to commit either version 👌🏼
#17
@
4 years ago
Updated, and added the "lint:jsdoc:fix": "wp-scripts lint-js --fix",
to fix some things automaticaly. There are still 900+ errors, might take some manual cleanup.
#18
@
4 years ago
@whyisjake A quick look at the 43828.5.diff I discovered that there are some unwanted changes in the src/wp-includes/nav-menu.php
file, the very last file when viewing the patch here on trac:
-
src/wp-includes/nav-menu.php
837 837 838 838 if ( $original_object ) { 839 839 $menu_item->url = get_permalink( $original_object->ID ); 840 /** This filter is documented in wp-includes/post-template.php */841 $original_title = apply_filters( 'the_title', $original_object->post_title, $original_object->ID );842 840 } else { 843 841 $menu_item->url = ''; 844 $original_title = '';845 842 $menu_item->_invalid = true; 846 843 } 847 844 848 if ( '' === $original_title ) { 849 /* translators: %d: ID of a post. */ 850 $original_title = sprintf( __( '#%d (no title)' ), $menu_item->object_id ); 851 } 845 $menu_item->title = $menu_item->post_title; 852 846 853 $menu_item->title = ( '' === $menu_item->post_title ) ? $original_title : $menu_item->post_title;854 855 847 } elseif ( 'post_type_archive' === $menu_item->type ) { 856 848 $object = get_post_type_object( $menu_item->object ); 857 849 if ( $object ) {
The patch is hard to review here on Trac, I think this is a good candidate to add a PR on GitHub, could you push up a PR and I'll review that there please?
This ticket was mentioned in PR #418 on WordPress/wordpress-develop by whyisjake.
4 years ago
#20
This is an bring in some changes to automate the testing of JSDoc blocks.
Trac ticket: https://core.trac.wordpress.org/ticket/43828
#21
follow-up:
↓ 22
@
4 years ago
@netweb, pull request here: https://github.com/WordPress/wordpress-develop/pull/418
#22
in reply to:
↑ 21
@
4 years ago
Replying to whyisjake:
@netweb, pull request here: https://github.com/WordPress/wordpress-develop/pull/418
Thanks, added some trivial'ish comments to the PR
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
4 years ago
dream-encode commented on PR #418:
4 years ago
#26
Merged into WP Core in https://core.trac.wordpress.org/changeset/48650
This would help a a lot when reviewing patches.
I am thinking, how hard would it be to add a check for the presence of
@since
?