Skip to content

Plugin Directory: Lint the theme's JavaScript, in CI - #954

Closed
obenland wants to merge 5 commits into
WordPress:trunkfrom
obenland:update/plugins-theme-js-lint
Closed

obenland wants to merge 5 commits into
WordPress:trunkfrom
obenland:update/plugins-theme-js-lint

Conversation

@obenland

Copy link
Copy Markdown
Member

Follow-up to #953 (Meta Trac #8446), which surfaced that the Plugin Directory theme's js/ directory was excluded from linting and that nothing lints the theme in CI.

Changes

Fix the theme build. npm run build fails on trunk:

  • The @wordpress/scripts migration (r14941) configured the global stylesheet entry as client/main.scss, but the style.scss → main.scss rename didn't make it into the commit. The rename matters: an entry named style makes webpack emit build/style-style.css.
  • The screenshots rework (r14950) deleted client/theme.js but kept its entry and the committed build/theme.js, which nothing enqueues.

Rebuilding the stylesheet drops the image gallery and .plugin-screenshots rules whose source r14950 removed; nothing references them any more (only the plugin-screenshots__* BEM classes are in use).

Format. npm run format on js/ and src/, in a formatting-only commit.

Lint. .eslintignore is replaced by eslint.config.js (ESLint 9 no longer reads the former), without the js/ exclusion. @wordpress/* imports are exempted from import/no-unresolved since they're script dependencies provided at runtime. Fixing the remaining errors turned up a few real bugs in section-categorization.js:

  • rest_name was never declared, so it leaked as a global.
  • button held the return value of classList.add() (always undefined), so the spinner never cleared after a successful save.
  • The form's controls were queried before the ! form check.

The four js/ scripts with hard-coded versions now use filemtime(), like the theme's other scripts, so the changes reach browsers.

CI. New plugins-theme-lint.yml, modeled on style-lint.yml, runs npm run lint:js on PRs and trunk pushes touching the theme's JS or package.json.

Notes

  • package-lock.json is gitignored repo-wide, so CI installs from package.json. @wordpress/scripts is pinned, but transitive dependencies float — which is also why only build/blocks/plugin-card/view.* is rebuilt here: a full rebuild changes every block bundle through toolchain drift alone (webpack runtime, asset.php formatting). For the same reason CI doesn't check build output for drift.
  • js/navigation.js and js/skip-link-focus-fix.js look like leftovers from the classic theme (no #site-navigation in the block templates; the skip-link fix targets old IE/Opera), but removing them is out of scope here.

Testing

  • npm run lint:js passes in the theme directory.
  • npm run build succeeds; build/style.css differs from trunk only by the removed gallery rules.

🤖 Generated with Claude Code

obenland and others added 4 commits September 29, 2026 08:49
The move to @wordpress/scripts expected the global stylesheet at client/main.scss, but the rename never landed, and the screenshots rework later removed client/theme.js without dropping its entry. Point the build back at existing files, remove the orphaned build/theme.js, and rebuild the stylesheet, which drops the image gallery styles whose source is already gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Apply `npm run format` so the files match the theme's @wordpress/scripts configuration. Formatting only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace .eslintignore, which ESLint 9 no longer reads, with an eslint.config.js that stops excluding js/, and fix what the linter reports:

- Declare the categorization form's REST field name instead of leaking it as a global.
- Keep a reference to the categorization button so its spinner clears after a successful save.
- Look up the categorization form's controls only once the form is known to exist.
- Use block-scoped declarations and explicit window globals throughout.

Version the affected scripts by file modification time, as the theme's other scripts already are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d85927da-ea5b-405e-a591-5872c1770481

📥 Commits

Reviewing files that changed from the base of the PR and between 1c8de1d and 4ad2dd1.

📒 Files selected for processing (29)
  • .github/workflows/phpcs.yml
  • .github/workflows/plugins-theme-lint.yml
  • .github/workflows/style-lint.yml
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/.eslintignore
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-card/view.asset.php
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-card/view.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/style-rtl.css
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/style.css
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/theme.asset.php
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/theme.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/client/main.scss
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/eslint.config.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/navigation.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/popover.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/section-categorization.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/section-faq.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/skip-link-focus-fix.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/stats.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/upload.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/archive-page/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/category-navigation/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/filter-bar/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/front-page/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-card/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-card/view.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/search-page/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/single-plugin/index.js
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/webpack.config.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props obenland.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Limit the token to reading contents, since the repository default grants write access. Don't persist that token in the checkout, and skip dependency install scripts, so third-party packages never run next to it. Pass the PHPCS base ref through the environment rather than interpolating it into the script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants