Opened 3 months ago
Closed 2 months ago
#65923 closed defect (bug) (fixed)
Exclude node_modules and built files from Grunt jshint:plugins
| Reported by: | afercia | Owned by: | afercia |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: | javascript |
Description (last modified by )
The Grunt task jshint:plugins was added in [28798] / #28464 to 'allow plugin developers easier access to JSHint and supports good coding standards'.
The task is excluded from grunt:precommit as it is only meant to be ran manually for plugin development. It also accepts a CLI flag with the plugin directory name to scan a single plugin.
grunt jshint:plugins grunt jshint:plugins --dir=query-monitor
However, after 12 years, many plugin now have their own built / minified / uglified JavaScript files. Not to mention development versions with a node_module directory.
In these cases, the task fails by either throwing errors or by hanging indefinitely.
Assuming this task is still useful for plugin development, it should be configured in a way to skip any node_module directory. Also, it should skip directories that typically contain built files or third party scripts.
To reproduce:
Install these plugins:
- Create Block Theme
- Gutenberg: clone the GitHub repository into the plugins directory and run
npm installto populate the pluginnode_modulesdirectory. - Query Monitor
- Yoast SEO
From the terminal in the WordPress root directory of a wordpress-develop install run grunt jshint:plugins.
Observe the task takes a very long time or even hangs indefinitely.
Try to run the task with only one of the above plugins installed, one at a time. Observe for some plugins that have built / minified files the task fails.
Change History (6)
This ticket was mentioned in PR #13207 on WordPress/wordpress-develop by @afercia.
3 months ago
#1
- Keywords has-patch added
#2
@
3 months ago
To test the linked PR https://github.com/WordPress/wordpress-develop/pull/13207
- Install a few more plugins that contain some JS files e.g.: Classic editor.
- Run
grunt jshint:plugins. - Observe the task completes in a few seconds and reports its findings, as expected.
The PR just adds an ignore property to the task configuration, excluding some of the most common directory names that contain JS files that aren't supposed to be linted.
The exclusion list can be certainly adjusted, if necessary.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: https://core.trac.wordpress.org/ticket/65923#ticket
Adds an
ignoreproperty to the Gruntjshint:pluginsto exclude any directory where the name contains:## Use of AI Tools
None