Fix ESLint plugin dependencies#368
Open
mariozenmedina wants to merge 1 commit into
Open
Conversation
Author
|
I accidentally clicked "Ready for review" while this PR was originally opened as a draft for maintainer feedback. I’ll leave it ready for now to avoid extra status noise, but the intended scope is still the same: this only fixes ESLint dependency/config resolution and does not address the existing lint violations. Feedback on whether this is the right direction is very welcome. |
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.
Description of the Change
Draft for maintainer feedback: this PR focuses only on fixing ESLint dependency resolution so
wp-scripts lint-jscan load the project configs. It does not attempt to fix the existing lint violations that are surfaced afterward.The root
.eslintrcextendsplugin:@wordpress/eslint-plugin/recommended, but@wordpress/eslint-pluginwas only available as a nested dependency of@wordpress/scripts. Because ESLint resolves plugins from the project config location, it could not find the WordPress ESLint plugin from the project root.There is a similar issue for Cypress linting:
tests/cypress/.eslintrcextendsplugin:cypress/recommended, buteslint-plugin-cypresswas not declared as a project dependency.After making those plugins resolvable, ESLint also reaches the WordPress config's TypeScript import resolver setup. The newer resolver interface is not compatible with this project's current ESLint 8 /
eslint-plugin-importstack, causing:Resolve error: typescript with invalid interface loaded as resolverThis PR pins
eslint-import-resolver-typescriptto3.5.5, which is compatible with the current ESLint stack.After this change,
wp-scripts lint-jsloads the configs/plugins successfully and reaches the existing lint violations, mostly CRLF/Prettier-related formatting errors, which are outside the scope of this PR.Closes #352
How to test the Change
Using Node 20, matching
.nvmrc:npm ci.npx wp-scripts lint-js.Expected result:
@wordpress/eslint-pluginoreslint-plugin-cypress.Resolve error: typescript with invalid interface loaded as resolver.I also validated config loading with:
./node_modules/.bin/eslint --print-config assets/js/blocks.js./node_modules/.bin/eslint --print-config tests/cypress/support/index.jsChangelog Entry
Credits
Props @mariozenmedina
Checklist:
Documentation and new tests were not added because this is a development dependency/configuration fix. Existing linting still reports pre-existing formatting issues after the dependency resolution problem is fixed.