Add/build tools - #2
Conversation
There was a problem hiding this comment.
Given the size of the pull request, I wasn't able to provide a scrutinous review of each change, but the general shape here looks good as a starting point for iteration. I recognize that this early in a project we may want to take some sweeping changes with project structure, which explains the scope of how the changes are presented. Where in the future we may want to split up into more focused pull requests.
For me, of my feedback, the biggest thing right now would be to evaluate whether to use @wordpress/build over @wordpress/scripts for building, as I understand it to be the preferred way of building plugins nowadays (related Developer Blog post).
| "rules": { | ||
| "selector-class-pattern": null | ||
| } |
There was a problem hiding this comment.
I assume this is overriding the BEM naming rule enforcement? Personally I think that could still be valuable to uphold. If needed we could treat existing issues as tolerated through suppressions and keep enabled for new code.
| @@ -0,0 +1,31 @@ | |||
| # Changelog | |||
|
|
|||
| All notable changes to this project will be documented in this file, per [the Keep a Changelog standard](http://keepachangelog.com/), and will adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |||
There was a problem hiding this comment.
If we intend to follow semantic versioning, I find that a style that highlights breakage more obviously (e.g. Gutenberg's "Breaking Changes" semantics) makes it easier to understand how a change should affect the version number, or something like conventional commits.
| ### Prerequisites | ||
|
|
||
| - Composer | ||
| - Node.js — the version is pinned in `.nvmrc`; the toolchain requires 22.12 or newer |
There was a problem hiding this comment.
We may want to align to WordPress/Gutenberg here. I think some other plugins have run into problems when trying to use a different version.
https://make.wordpress.org/core/handbook/references/wordpress-branches-and-node-js-npm-versions/
Current is 20, but this will update soon to 24 with WordPress/gutenberg#72973.
| '**/build/**', | ||
| '**/node_modules/**', | ||
| '**/vendor/**', | ||
| '*.config.js', |
There was a problem hiding this comment.
The others make sense as vendored or transient build artifacts, but this one I think we should omit and enforce linting.
| '*.config.js', |
| // ─── Snackbars ────────────────────────────────────────────────────────── | ||
| // Match the AI plugin: pin the snackbar list to the bottom-left of the | ||
| // viewport, offset just past the admin sidebar so it doesn't disappear | ||
| // behind the menu. The list stays fixed to the viewport, so it remains | ||
| // visible regardless of scroll position (up to the auto-dismiss timeout). | ||
|
|
||
| .components-snackbar-list { | ||
| position: fixed; | ||
| inset-block-end: 20px; | ||
| inset-inline-start: 176px; // WP admin sidebar (~160px) + 16px gutter. | ||
| inset-inline-end: auto; | ||
| width: auto; | ||
| max-width: min( 480px, calc( 100vw - 200px ) ); | ||
| padding: 0; | ||
| } |
There was a problem hiding this comment.
Not a blocker since it already existed and is beings shuffled around here, but as a stakeholder in the Gutenberg Components team, I'd wonder if this is signaling an issue that's better fixed upstream. Usually overriding the component styles like this is not recommended.
|
|
||
| td span { | ||
| color: var(--wpds-color-content-onSurface-secondary, #757575); | ||
| color: #757575; |
There was a problem hiding this comment.
I'm guessing that the lint flagged this as a violation of a non-existing token, but a better solution may be to pick an existing token instead.
One other related consideration as we set up build tooling is that @wordpress/build bakes in build-time design token fallbacks.
Generally I would expect that as part of setting up the build aparatus, we may want to prefer @wordpress/build over @wordpress/scripts for building, as it's the newer, preferred option for plugins stemming from work in WordPress/gutenberg#72032 .
|
This PR should have stopped with the build tools and alignment to standards should have been done in subsequent PRs. Close this in lieu of #7 |
|
Apologies @aduth, I didn't realize you had a review in progress. I closed this based on it being too large and opened up #7. I will review all your comments in this PR and check them against my other PR and make note of anything that remains relevant. I appreciate you taking the time to review, thank you! |
What?
Adds a first pass at build tooling for the plugin: linting, static analysis, continuous integration, a pre-commit hook, and contributor documentation — plus the code fixes those tools surfaced.
Why?
The plugin had no automated quality checks. Coding standards, static analysis and CI were all missing, so nothing enforced consistency and nothing verified a branch before review. This establishes the basics so future work has a baseline to build on.
Standing the tooling up also surfaced a set of real defects in the existing code that no one had a way to catch. Those are fixed here rather than deferred, since several of them are one-line changes and leaving them would mean merging a red build.
How?
Tooling added
npm run lintandnpm run format.lint-stagedon staged files, followed by a project-wide PHPStan (it can't be scoped to staged files, as it needs whole-codebase context to resolve types)..nvmrcpinning Node,.editorconfigfor shared editor settings, andwp-envscripts (env:start,env:stop,env:clean).CONTRIBUTING.md, a pull request template, andCHANGELOG.md.Fixes surfaced by the tooling
$_POST['value']throughwp_unslash()without sanitizing. Every branch already validated against an allowlist or cast to int before storing, so nothing was exploitable — this closes the gap ahead of that point.uninstall.phpassigned to$plugin, which collides with a WordPress global.Registryit never read (the React app fetches over REST instead).Known follow-ups, deliberately not in this PR
Heading_OrderandBlock_Validation_Frameworklive underModules/Experiments/and are documented as Experiments, but both returnBucket::FEATURE/Track::PRACTICAL. All six modules currently report Feature/Practical, so the Experiment and Core-track badges never render in the settings UI. Left for a separate fix, since it changes behaviour rather than tooling.github.com/WordPress/accessibility-labto match the plugin header's Plugin URI. Those will 404 until the repository moves to the WordPress organisation.Testing Instructions
Check out the branch and install from the lock files:
Confirm all four linters pass:
Expect no output from ESLint or Stylelint,
12 / 12 (100%)from PHPCS, and[OK] No errorsfrom PHPStan.Confirm the build succeeds and produces all five bundles:
Confirm the pre-commit hook blocks a bad commit — introduce a deliberate lint error in any file under
src/, stage it, and attempt to commit. The commit should abort. Revert afterwards.Confirm CI is green on this PR. The JS job reaching the "Build" step is the meaningful signal, since it previously failed at "Install dependencies".
Smoke-test the plugin itself, since this PR reformats source files. No behavioural or visual change is intended:
upload.phpand the modal) — the view-options button opens its popover; density, items-per-page and filename toggles apply and persist across reloads.Changelog Entry
Full entries for this PR are in
CHANGELOG.mdunder[Unreleased], split across Added, Changed and Fixed.