Skip to content

Migrate ESLint config to flat config and fix linting on fork PRs - #1406

Open
adamsilverstein wants to merge 2 commits into
10up:developfrom
adamsilverstein:fix/eslint-config
Open

adamsilverstein wants to merge 2 commits into
10up:developfrom
adamsilverstein:fix/eslint-config

Conversation

@adamsilverstein

Copy link
Copy Markdown

Found while chasing a red eslint check on #1405. Claude tracked down the cause and wrote the fix:

Description of the Change

The eslint job has been failing on develop since the @wordpress/scripts 35 bump in #1398. That version runs ESLint 9, which ignores .eslintrc.json and .eslintignore. Every lint run was quietly falling back to the default wp-scripts config, so the Cypress globals, the ignores (including wp-hooks-docs/) and the import/core-modules settings were all dropped. That leaves 655 errors, nearly all no-undef on cy.

  • Port .eslintrc.json, .eslintignore and tests/cypress/.eslintrc.json into one eslint.config.js that extends the wp-scripts default.
  • Bump eslint-plugin-cypress from 2.12.1 to 3.6.0 for its flat config. Only its plugin, globals and rules are pulled in, because its ecmaVersion: 2019 breaks parsing of optional chaining in the support files.
  • Fix what the newer rules still report: three .click().type() chains (.type() already clicks) and two duplicate /*eslint camelcase: 0*/ comments.
  • Skip the annotate step on fork PRs. It needs checks: write, which a fork PR token never has, so the job failed with Resource not accessible by integration even when there were zero errors. For forks, the lint step now fails the job directly, and the existing summary step still reports the errors.

How to test the Change

  • npm ci && npm run lint:js reports 0 errors (one existing unused-directive warning).
  • The eslint check on this PR passes. It comes from a fork, so it exercises the fork path.

Checklist:

Changelog Entry

Developer - Migrate ESLint config to the flat config format and fix linting on fork pull requests.

Credits

Props @adamsilverstein

AI Use

Claude Code wrote both the config migration and this description. I will review and test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MWLpjMiZ5cyR6nBxhTz9z7

adamsilverstein and others added 2 commits September 24, 2026 22:15
@wordpress/scripts 35 runs ESLint 9, which ignores .eslintrc.json and
.eslintignore. The repo config, ignores and Cypress globals were silently
dropped, leaving 655 errors on develop. Port them to eslint.config.js,
bump eslint-plugin-cypress to 3.6 for its flat config, and fix the few
real issues the newer rules report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MWLpjMiZ5cyR6nBxhTz9z7
The annotate action needs checks: write, which fork PR tokens never
have, so the eslint job always failed on forks. Fail on the lint step
directly for forks instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MWLpjMiZ5cyR6nBxhTz9z7

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Code Review

Development

Successfully merging this pull request may close these issues.

2 participants