Skip to content

Clean up block implementation - #222

Merged
matt-bernhardt merged 11 commits into
block-remixfrom
cleanup
Sep 14, 2026
Merged

matt-bernhardt merged 11 commits into
block-remixfrom
cleanup

Conversation

@matt-bernhardt

@matt-bernhardt matt-bernhardt commented Sep 9, 2026

Copy link
Copy Markdown
Member

This proposes a few cleanup steps to the blocks plugin materials:

  1. We change how we declare dependencies, from saying "use the latest" to "use a specific version". This appears to have been the source of our problems with the "ensure block build artifacts are current" CI step. This also moves everything into the "devDependency" block, because WordPress is still not a JS-based application - everything we're declaring is used during developer workflows.
  2. Some unused portions of the boilerplate block are removed - including the use of view.js, the declaration of a "main" element in package.json, and certain dependencies like __ and useBlockProps for PHP-rendered blocks.
  3. A lot of linter-inspired cleanup and tweaking of code. NPM provides an auto-format command - npm run format that will handle a lot of simple things, and then npm run lint:js will flag more complex issues that need human hands. On the PHP side, there wasn't as much to do, so composer lint web/app/plugins/mitlib-blocks showed a handful of lines that needed changing.
  4. A last-minute update of package-lock.json to make sure everything is in sync, and then a re-run of the build process to account for all of the above changes.

My recommendation is to look at the commits one-by-one if you want to understand what is changing in a systematic way. Reviewing the overall changes is going to conflate a lot of things together, although that could be helpful if you're reading from the perspective of "can I continue to work with these files as-is?"

Most of these blocks don't use this boilerplate file, which only had a
console.log statement. In those cases, we remove the file entirely, as
well as the entry in block.json which called for it to be loaded.
These blocks aren't part of a javascript application stack, so there is
no need to declare an entry point into their materials.
The boilerplace declares wordpress dependencies to _always_ use the
latest version, which causes problems in our CI workflow because a new
release may have become available between when the developer started a
branch and when the CI runs to evaluate it.

Keeping branches short-lived is only a partial solution. The more robust
option is to declare our dependencies using a predictable version. This
provides for consistency between environments (among developers, and
with our CI workflows).

The cost of this is that we need to manage dependency updates ourselves,
but this is already something we are doing.
The javascript community has a set of formatting rules which they've
adopted, and their tooling will automatically apply that formatting.

This commit applies the changes necessary for `npm run lint:js` to
return no output.

(We can tweak the rules that it applies as we go forward - some of these
seem pretty silly to me - but having those discussions will take time to
reflect and reach consensus, and we want to get this branch done quickly
for the moment.
This is part of the NPM linter, but there were so many of these changes
that it seemed better to split them out into their own commit.
Use of ' instead of ' causes complaints by the linter...
@matt-bernhardt
matt-bernhardt force-pushed the cleanup branch 2 times, most recently from 33d863c to 12f9ca3 Compare September 14, 2026 15:13
@matt-bernhardt
matt-bernhardt marked this pull request as ready for review September 14, 2026 15:15
The boilerplate included an import of useBlockProps - but then did not
actually make use of it. Our choice is to either finish the
implementation, or to stop importing it in the first place.

I initially tried to actually implement this library for the blocks that
are not rendered via render.php, but this resulted in editor-facing
styles leaking out to the public UI.

Instead, I've opted to remove the import entirely. It does not appear to
impact how our defined options are updated via the editor interface, so
I don't think this is something we need at this time.
The featured collection never passes any output through a translation
function, so we do not need to import it in the first place.
This is the same fixup step for the PHP files as we previously took for
the JS files. Run the linter, note what it complains about, and then fix
those lines until the linter reports no output.
This keeps everything in sync with the latest releases of our tooling

@djanelle-mit djanelle-mit 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.

Changes LGTM! I did not see any style issues on the rendered versions of the blocks, and the editable portions all work as expected.

The linting rules do seem a little persnickety to me, especially putting each attribute on it's own line, but happy to align on what we'd like those to do in a future chunk of work (after we wrap up this first feature branch).

@matt-bernhardt
matt-bernhardt merged commit dd1eeb2 into block-remix Sep 14, 2026
7 checks passed
@matt-bernhardt
matt-bernhardt deleted the cleanup branch September 14, 2026 19:55
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