Skip to content

Theme: Fix all lint errors and warnings - #83

Open
obenland wants to merge 1 commit into
update/npm-wp-scriptsfrom
fix/lint
Open

obenland wants to merge 1 commit into
update/npm-wp-scriptsfrom
fix/lint

Conversation

@obenland

Copy link
Copy Markdown
Member

Stacked on #82, which adds the lint tooling and configs. Merge that first; this PR's base will then switch to trunk.

After this, npm run lint:js, lint:css and lint:php all pass with 0 errors and 0 warnings. Ignoring whitespace, the diff is +202/−810; most of the rest is re-indentation from wrapping scripts in IIFEs and removing a dead if ( false ) branch. Review with "Hide whitespace".

JS

  • Every script is now wrapped in an arrow IIFE and uses const. Swapping var for const directly isn't safe: these are classic scripts sharing one global scope, and several declare the same names (el in three files, __, …). Top-level const would throw a redeclaration SyntaxError and stop the script.
  • The demo blocks' edit functions are now named Edit components, so useBlockProps() satisfies react-hooks/rules-of-hooks.
  • editor-modifications.js uses window.FileReader. A file-wide /* eslint-disable no-undef */ had been hiding that FileReader wasn't a known global.
  • The Openverse picker's JSDoc types are complete (no more Function types), plus Prettier formatting.

CSS

  • The duplicate .interface-interface-skeleton rule is merged into one.
  • Removed the @media (max-width: 782px) rule. Its inline // comment made the selector invalid, so it never applied. The .admin-bar rule after it already covers that breakpoint, because Blockbase sets --wpadmin-bar--height to 46px on mobile.
  • The long outline-button selectors are broken at a descendant combinator. Same selector, same specificity.

PHP

  • Dead code removed:
    • The if ( false ) static-mobile branch, which was disabled in ece1110. Its only assets, gutenberg-content-mobile.php and style-mobile.css, are deleted too, along with the now-unused $hook parameter.
    • The editor-styles loop. get_block_editor_settings() overwrites styles with core's own (array_merge( $global_styles, get_block_editor_theme_styles() )), so it never had an effect. It also used file_get_contents().
    • frontenberg_site_title(), orphaned since its filters were removed in 3ff0c32.
    • The $GLOBALS['wp_rich_edit'] write. The user_can_richedit filter right after it already forces true.
  • Enqueues: script versions use filemtime(), and $in_footer is now explicit. They stay in the header, which preserves the current load order. postbox keeps its theme registration with core's version, plus a comment on why it's needed: core only registers postbox in wp-admin, and wp-edit-post depends on it. I found that out by removing it.
  • 'gutenberg' text domain strings are now 'wporg', plus wp_json_encode(), wp_parse_url(), a Yoda condition, file and function doc comments, and phpcbf formatting.

Testing

Chrome, local wp-env on WP 7.2-beta1, logged out, fresh localStorage:

  • No PHP notices and no console errors or notices. All 188 blocks load, with the expected title.
  • The demo button and link blocks register and render. The outline button keeps its transparent background and 1px border.
  • The W button, welcome guide off, fullscreen on, sidebar closed on load, publish sidebar disabled, saving locked.
  • core/shortcode unregistered, "Submit for Review" shows as "Publish", the URL stays on /, and no unload warning after edits.
  • Uploads work through the fake media endpoint, the Openverse picker opens, and there are no users/me requests.
  • Rich editing is on, the editor gets core's theme styles (8), postbox loads, and the editor layout offsets are 0 with fullscreen on and off.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings October 23, 2026 20:59

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 insufficient remaining quota.

JS (wp-scripts lint-js):
- Wrap every script in an arrow IIFE and use const: classic scripts share the
  global scope and several declare the same names (el, __, ...), so top-level
  const would throw a redeclaration SyntaxError.
- Name the demo blocks' edit functions Edit, so useBlockProps() is called from
  a component (react-hooks/rules-of-hooks).
- Use window.FileReader instead of a file-wide no-undef disable.
- Complete the Openverse picker's JSDoc types; Prettier formatting.

CSS (wp-scripts lint-style):
- Merge the duplicate .interface-interface-skeleton rule.
- Remove the @media rule whose '//' comment made its selector invalid, so it
  never applied; the .admin-bar rule after it covers that breakpoint through
  Blockbase's --wpadmin-bar--height.
- Break the long outline-button selectors at a descendant combinator.

PHP (PHPCS):
- Remove the dead if ( false ) mobile branch, the unused $hook parameter, and
  the mobile-only gutenberg-content-mobile.php and style-mobile.css.
- Remove the editor styles loop: get_block_editor_settings() overwrites
  'styles' with core's own, so it was dead (and used file_get_contents()).
- Remove frontenberg_site_title(), orphaned since its filters were dropped,
  and the wp_rich_edit global write, which the user_can_richedit filter
  already covers.
- Version and explicit in_footer for script enqueues; postbox gets core's
  version (and a note on why the theme registers it at all).
- 'gutenberg' text domain strings to 'wporg', wp_json_encode, wp_parse_url,
  Yoda, doc comments, and phpcbf formatting.

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