Skip to content

Fix lint concerns part 2: Files related to the validation framework - #19

Open
troychaplin wants to merge 5 commits into
mainfrom
fix/lint-concerns-validation-framework
Open

troychaplin wants to merge 5 commits into
mainfrom
fix/lint-concerns-validation-framework

Conversation

@troychaplin

@troychaplin troychaplin commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Part 2 of 6 in the lint/QA cleanup series (#16). The series ends with the project's build tools (ESLint, Stylelint, PHPCS and PHPStan) enforced on main through CI and the pre-commit hook. This PR is one small, self-contained step toward that.

What?

Part of #16

Clears the ESLint, Stylelint, PHPCS and PHPStan findings for [feature name], limited to the files listed for this PR in #16. No functional changes are intended; any exceptions are called out under How?.

Why?

The lint and static-analysis tooling was added after most of the plugin was written, so the codebase fails its own checks today, and CI and the pre-commit hook are switched off so work isn't blocked. Rather than one large PR that's hard to review, the cleanup is split by feature:

  1. Fix lint concerns part 1: Base plugin files #18 Base / core plugin infrastructure: bootstrap, module registry, and the top-level settings screen.
  2. Fix lint concerns part 2: Files related to the validation framework #19 Validation Framework: the block-validation runtime/engine.
  3. Fix lint concerns part 3: Core block rules #20 Core Block Validation Rules: the per-block rule set (button, gallery, heading, image, post-title, table).
  4. Fix lint concerns part 4: Validation settings #21 Validation Settings: the validation feature's own settings and admin UI.
  5. Fix lint concerns part 5: Media library views #22 Media Library View Config: the media-library accessibility feature.
  6. Fix lint concerns part 6: Enable enforcement of standards #23 Finalization: turns CI and the Husky pre-commit hook back on once 1–5 are merged.

Each of PRs 1–5 touches only its own feature's files (the PHP plus the JS/SCSS that goes with it). They don't depend on each other and can be reviewed and merged in any order. PR 6 merges last, because it's the one that switches enforcement on.

How?

Most of the diff is mechanical: auto-fixed formatting, missing docblocks, and naming-convention renames. Anything that needed a judgement call is listed below so it gets a proper look. That includes lint suppressions, small refactors made to satisfy a rule, and real issues the linters surfaced.

Judgement calls in this PR:

  • [one bullet each, or "None, mechanical fixes only."]

Testing Instructions

  1. Check out this branch and run nvm use (the repo requires Node 24).
  2. Run the linters against this PR's files (listed for this PR in [Task]: Lint/QA Cleanup #16). All four should pass:
vendor/bin/phpcs \
  includes/Modules/Experiments/Block_Validation_Framework.php \
  includes/Modules/Experiments/BlockValidation/Check_Key.php \
  includes/Modules/Experiments/BlockValidation/Check_Registry.php \
  includes/Modules/Experiments/BlockValidation/Global_Functions.php \
  includes/Modules/Experiments/BlockValidation/Rest_Controller.php

vendor/bin/phpstan analyse --memory-limit=2048M \
  includes/Modules/Experiments/Block_Validation_Framework.php \
  includes/Modules/Experiments/BlockValidation/Check_Key.php \
  includes/Modules/Experiments/BlockValidation/Check_Registry.php \
  includes/Modules/Experiments/BlockValidation/Global_Functions.php \
  includes/Modules/Experiments/BlockValidation/Rest_Controller.php

node_modules/.bin/wp-scripts lint-js src/editor/framework
node_modules/.bin/wp-scripts lint-style "src/editor/framework/**/*.scss"

node_modules/.bin/wp-scripts build

@github-actions

github-actions Bot commented Sep 18, 2026 •

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: troychaplin <areziaal@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@joedolson joedolson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If there's any possibility this could get migrated to core, it'll be important that API methods use the spelling expected in core; and even if it doesn't, it'll be slightly easier to manage if the same expectations are followed as core has. So renaming the normalise method to normalize would be a good idea.

@troychaplin

Copy link
Copy Markdown
Member Author

@joedolson I believe all spelling has been updated. I was also curious if there was any options around "linting" for this, so after a short search I put together #35 for consideration.

troychaplin and others added 2 commits November 12, 2026 07:38
`useMetaField` still emitted `validation-api-meta-field--${worst}`, the one
`--` modifier left after this branch's rename. No linter catches it:
stylelint reads only stylesheets, and ESLint does not inspect class-name
strings.

Converts it along with the flattened `validation-issue-${severity}` to the
`is-*` form, so the modifier convention matches #18 rather than landing a
second idiom.

`validation-api-block-error` / `-warning` are left alone — they are
documented public API, not modifiers on a base class.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@troychaplin

Copy link
Copy Markdown
Member Author

Thanks @joedolson — spelling is sorted. normalise → normalize throughout, including the method, the docblocks you flagged, and Check_Key. I also swept this PR's files for other British spellings (colour, behaviour, initialis, serialis, optimis, centre, licence, analyse) — all clean.

One extra thing I caught while in here, flagging rather than slipping it in: useMetaField.ts was still emitting validation-api-meta-field--${worst}, the one -- modifier left after this branch's rename. No linter catches it — stylelint only reads stylesheets, and ESLint doesn't inspect class-name strings.

Converted it, plus the flattened validation-issue-${severity}, to is-* so the modifiers match #18:

.validation-issue {
	&.is-error   .validation-issue-button svg { fill: #cc1818; }
	&.is-warning .validation-issue-button svg { fill: #dba617; }
}

validation-api-block-error / -warning are untouched — documented public API in docs/features/validation-api.md, not modifiers on a base class.

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