Make WordPress Core

Opened 6 weeks ago

Closed 3 weeks ago

Last modified 2 weeks ago

#62935 closed defect (bug) (fixed)

Fix JavaScript linting scripts

Reported by: desrosj's profile desrosj Owned by: jorbin's profile jorbin
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

The lint:jsdoc and lint:jsdoc:fix scripts are currently broken.

These should get fixed.

Additionally, the related ink-docstrap direct dependency has not been updated in 7+ years. Under the hood, these scripts use wp-scripts so ink-docstrap may not even be necessary anymore. Ideally we are able to trim this dependency if the results are styled using other means in wp-scripts.

ink-docstrap was introduced in [41351], and the scripts were switched to using wp-scripts in [48650].

Change History (16)

This ticket was mentioned in PR #8295 on WordPress/wordpress-develop by @ankitkumarshah.


6 weeks ago
#1

  • Keywords has-patch added; needs-patch removed

Trac ticket: #62935

## Description
This PR updates the wp-prettier dependency from version 2.6.2 to 3.0.3 and refines the ESLint ignore patterns for better build management. The changes aim to fix the issues with lint:jsdoc and lint:jsdoc:fix scripts.

## Changes proposed in this Pull Request

  • Upgrade wp-prettier from 2.6.2 to 3.0.3 to resolve JS linting issues
  • Update .eslintignore patterns to be more specific:
    • Add build-module and build-types directories
    • Replace /build with build for consistency
    • Add *.min.js pattern to ignore minified files
    • Update wp-includes JS ignore pattern

## Testing Instructions

  1. Run npm install to update dependencies
  2. Run npm run lint:jsdoc to verify linting works
  3. Run npm run lint:jsdoc:fix to verify auto-fixing works
  4. Verify that build directories are properly ignored

## Screenshots
https://github.com/user-attachments/assets/524ed431-1fff-4b58-a5e4-9837fe91defd

#2 @ankitkumarshah
6 weeks ago

Hi @desrosj,
I have tried a solution and opened a PR that potentially resolves the issue could you please review and test it at your convenience.

Thank you!

@jorbin commented on PR #8295:


5 weeks ago
#3

@Infinite-Null Taking a look at this, the update of wp-prettier seems to be the only thing necessary. Can you explain why you think we also need to "Update .eslintignore patterns to be more specific"

@ankitkumarshah commented on PR #8295:


5 weeks ago
#4

Hi @aaronjorbin,

Thank you for your feedback! I added those ignore rules because when I ran npm run lint:jsdoc -- --debug, I noticed that it was also running for .min.js files and build directories like src/wp-content/plugins/gutenberg/build. Since these files are not meant for linting, I believed excluding them would be appropriate.

Please guide me if I am wrong.

@jorbin commented on PR #8295:


5 weeks ago
#5

Thanks for the quick response and explanation.

I think bringing .eslintignore more inline with .gitignore will make more sense. For example, the `# Files and folders that get created in wp-content` section can be used to block any plugins code from being scanned.

`# Files and folders related to build/test tools`
contains a number of folders worth excluding as well since those aren't being directly edited as a part of core development.

@ankitkumarshah commented on PR #8295:


5 weeks ago
#6

Hi @aaronjorbin,
Thanks for the feedback! I’ve updated .eslintignore to better align with .gitignore. Please review the changes and let me know if any further adjustments are needed.

@ankitkumarshah commented on PR #8295:


5 weeks ago
#7

Hi @aaronjorbin,
Thank you for the feedback!
I have made the changes, please review it at your convenience.

#8 @jorbin
5 weeks ago

  • Focuses docs removed
  • Milestone changed from Future Release to 6.8

ink-docstrap was put in for the purposes of creating documentation that could live on developer.wordpress.org but it looks like that has stalled. See https://meta.trac.wordpress.org/ticket/3063

I don't know if removing it needs to be a part of this or if there are folks using it, but moving this ticket into 6.8 since fixing the eslinting is better done sooner than later.

#9 @jorbin
5 weeks ago

In 59848:

Build/Test: Fix JavaScript linting scripts

wp-prettier was out of date and no longer compatible with wp-scripts. Additionally, many generated files and plugins were not being properly ignored which could cause linting to take so long that it was basically unusable.

Props ankitkumarshah, jorbin.
See #62935.

@jorbin commented on PR #8295:


5 weeks ago
#10

Committed in https://core.trac.wordpress.org/changeset/59848

Thanks @Infinite-Null !

#11 @jorbin
3 weeks ago

  • Owner set to jorbin
  • Status changed from new to assigned

@desrosj Do you still think ink-docstrap needs to be addressed? I think we are fine keeping it as is

#12 @desrosj
3 weeks ago

My motivation around suggesting we eliminate or replace that package is that there are currently a small handful of minor vulnerabilities within transitive dependencies being privately reported by Dependabot that cannot be resolved due to version constraints within ink-docstrap.

#13 @jorbin
3 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 59935:

Build/Test: Remove unused ink-docstrap.

jsdoc is not currently in use and this theme for it is very out of date. There are currently a small handful of minor vulnerabilities within transitive dependencies being privately reported by Dependabot that cannot be resolved due to version constraints within ink-docstrap. While this in no way affects WordPress (since this code is not used by WordPress), it does create noise which can be eliminated.

This was first added in [41351] as a part of #41682.

Props desrosj.
Fixes #62935.

#14 @johnbillion
2 weeks ago

@jorbin @desrosj If jsdoc isn't being used shall we just go ahead and remove it? The npm run grunt jsdoc command successfully creates the docs but also exits with a bunch of parse errors.

#15 @ankitkumarshah
2 weeks ago

I think it is safe to remove jsdoc. Would love to work on this after hearing from @jorbin and @desrosj.

#16 @desrosj
2 weeks ago

I don't know that we should remove jsdoc. There are two linting scripts that use wp-scripts in package.json. If we were to remove jsdoc as a direct dependency and Grunt, we should figure out what the differences are and how to synchronize the configurations.

Note: See TracTickets for help on using tickets.