Replace @wordpress/scripts with direct eslint dependency#215
Merged
Replace @wordpress/scripts with direct eslint dependency#215
@wordpress/scripts with direct eslint dependency#215Conversation
The repo only uses @wordpress/scripts for JS linting (wp-scripts lint-js), but it pulls in 60 direct dependencies (webpack, jest, puppeteer, sass, stylelint, etc.) that are entirely unused. These transitive dependencies have been a recurring source of npm audit vulnerabilities. Replace the wp-scripts wrapper with a direct eslint call and add a root .eslintrc.js configured for the repo directory structure. Add @babel/core as a direct dependency required by @wordpress/eslint-plugin for AST parsing, and set jest.version in eslint settings since jest is no longer installed as a transitive dependency.
The stylelint module is provided at runtime by the GitHub Actions environment rather than as a direct dependency. This was previously masked by @wordpress/scripts bundling stylelint as a transitive dependency.
Add an npm override to resolve minimatch from 9.0.3 to 9.0.9, fixing ReDoS vulnerabilities (GHSA-3ppc-4f35-3m26, GHSA-7r86-cg39-jmmj, GHSA-23c5-xmqv-rm74) in the transitive dependency chain from @wordpress/eslint-plugin.
There was a problem hiding this comment.
Pull request overview
This PR replaces @wordpress/scripts with direct eslint and @babel/core dependencies to reduce the dependency tree from ~3,700 to ~1,300 packages (65% reduction) and eliminate recurring npm audit vulnerabilities. The change addresses the root cause rather than treating symptoms through individual overrides.
Changes:
- Removed
@wordpress/scriptsdependency and replaced with directeslintand@babel/coredependencies - Migrated inline
eslintConfigfrom package.json to a standalone.eslintrc.jsfile with improved configuration including jest version settings - Added
import/no-unresolvedsuppression for stylelint import in the stylelint formatter to account for the external dependency pattern
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| package.json | Removed @wordpress/scripts; added eslint, @babel/core; moved eslintConfig to separate file; added minimatch override for security fix |
| .eslintrc.js | New ESLint configuration file with settings for import resolver, jest version, and ignore patterns including .github/ and vendor/ |
| packages/github-actions/actions/stylelint-annotation/src/stylelintFormatter.js | Added import/no-unresolved to eslint-disable comment for stylelint import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
This repo only uses
@wordpress/scriptsfor JS linting (wp-scripts lint-js), but the package pulls in 60 direct dependencies (webpack, jest, puppeteer, sass, stylelint, etc.) that are entirely unused. These transitive dependencies have been a recurring source ofnpm auditvulnerabilities (e.g., minimatch, webpack-dev-server, markdownlint-cli, ajv, axios).What changed:
@wordpress/scriptsand replace with directeslintand@babel/coredependencies.eslintrc.jsconfigured for the repo directory structure, replacing the inlineeslintConfiginpackage.jsonjest.versionin eslint settings soeslint-plugin-jestworks without thejestpackage (previously provided by@wordpress/scripts)import/no-unresolvedforstylelintinstylelintFormatter.js, which was previously masked by@wordpress/scriptsbundlingstylelintas a transitive dependencyminimatchin@typescript-eslint/typescript-estreeto fix the remaining transitive ReDoS vulnerabilityWhy this approach over adding more overrides:
An alternative considered was keeping
@wordpress/scriptsand adding npm overrides for each vulnerable transitive dependency (minimatch, webpack-dev-server, markdownlint-cli). While that resolves the current audit issues, it treats the symptoms rather than the cause. Each future vulnerability in any of the ~3,700 transitive packages would require a new override. Removing@wordpress/scriptsreduces the dependency tree to ~1,300 packages (65% reduction) and eliminates the recurring maintenance burden.Audit result:
The current
trunk43b1ec7 has 11 vulnerabilities (2 moderate, 9 high). This PR resolves all of them to 0.Detailed test instructions:
npm installpackage-lock.jsonhas no new changes viagit diffnpm run lint:jsnpm audit