Make WordPress Core

Opened 11 hours ago

Last modified 11 hours ago

#66123 assigned defect (bug)

Grunt jshint:plugins: Exclude minified files more effectively

Reported by: afercia Owned by: afercia
Priority: normal Milestone: 7.2
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch
Cc: Focuses: javascript

Description

Follow-up to #65923.

When running grunt jshint:plugins minified JavaScript files that don't use a .min suffix in their filename are still scanned.

Minified files should be excluded even when they don't use a .min suffix as JSHint can't really check a file that is minified in a meaningful way. Also, scanning a minified file takes a long time and produces a huge dump in the shell with no significant report.

To reproduce the issue:

The issue may get even more serious if more plugins use more minified files that don't follow the .min suffix naming convention.

Change History (3)

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


11 hours ago
#1

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/66123#ticket

Exclude minified files from the grunt jshint:plugins task by checking the JS files line length.
The assumption is that when a JS file contains lines with a length that is lonver than 500 characters, then it is considered a minified file and it will be skipped.

Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Haiku 4.5
Used for: Initial research and suggestions; final implementation and tests were reviewed and edited by me.

#2 @afercia
11 hours ago

In https://github.com/WordPress/wordpress-develop/pull/13573 the existing filter for the task is extended to exclude also JS files that contain lines longer than 500 characters.
The assumption is that such long lines are typically present only in minified files while source code usually does not contain such long lines.

To test:

  • With the installed plugins suggested above.
  • Run grunt jshint:plugins.
  • Observe the task completes with no errors and no huge dumps of the minified files content.
  • Observe the task logs to the console the message: Skipping minified file: src/wp-content/plugins/folders/assets/js/lottie-player.js.
  • Run the task with the --dir flag to verify the ability to scan a single plugin is preserved, for example: grunt jshint:plugins --dir=view-admin-as.

Instead of checking for the lines length, an alternative approach could be checking for the character-to-whitespace ratio, which is typically very low for minified files. It could fail for files with very little content though.

Last edited 11 hours ago by afercia (previous) (diff)

#3 @afercia
11 hours ago

  • Owner set to afercia
  • Status newassigned
Note: See TracTickets for help on using tickets.