Skip to content

Add block plugin validator classes and form - #1

Open
tellyworth wants to merge 23 commits into
masterfrom
experiment/block-checker
Open

Add block plugin validator classes and form#1
tellyworth wants to merge 23 commits into
masterfrom
experiment/block-checker

Conversation

@tellyworth

@tellyworth tellyworth commented Jun 11, 2020

Copy link
Copy Markdown
Owner

This adds a [block-validator] shortcode, based on the readme-validator, which runs a bunch of validation checks on block plugins. It incorporates @coreymckrill's block.json validator.

Also included is a CLI script, bin/check-block.php. If you run it without arguments, it will output validation results for all plugins currently in the block directory. Or use php bin/check-block.php --slug waves to run it on a single plugin.

@tellyworth tellyworth changed the title Move changes from https://github.com/tellyworth/wordpress.org/pull/1 Add block plugin validator classes and form Jul 1, 2020
@tellyworth
tellyworth requested review from coreymckrill and dd32 July 1, 2020 07:11
Comment thread cli/class-block-plugin-checker.php
Comment thread cli/class-block-plugin-checker.php Outdated
Comment thread cli/class-block-plugin-checker.php Outdated

@dd32 dd32 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.

Mostly looks good to me, the only thing I really noticed was not excluding svn:externals by default.

Comment thread cli/class-import.php
protected function find_readme_file( $directory ) {
$files = Filesystem::list_files( $directory, false /* non-recursive */, '!^readme\.(txt|md)$!i' );
static function find_readme_file( $directory ) {
$files = Filesystem::list_files( $directory, false /* non-recursive */, '!(?:^|/)readme\.(txt|md)$!i' );

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.

Given this is a non-recursive search, is /readme.. ever going to be hit?

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.

I now figure that this change was probably mostly for consistency with the recursive searches added elsewhere.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

list_files() seemed to be matching against the full path, including the $directory prefix. With the ^ assertion only, it doesn't match any files. There might be something contextual here that's causing different behaviour, as otherwise find_readme_file() wouldn't work at all.

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.

Odd, it must be working at present though..

sprintf(
__( 'At least one of the following properties must be present: %s', 'wporg-plugins' ),
// translators: used between list items, there is a space after the comma.
'<code>script</code>' . __( ', ', 'wporg-plugins' ) . '<code>editorScript</code>'

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.

It hardly seems worth translating a comma.. unless it's used elsewhere.

I was going to suggest wp_sprintf_l( '%l' ) could be used here, but that would generate X and Y not X or Y.

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.

Today I Learned about the existence of wp_sprintf_l()...

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.

The translated comma and translator hint is lifted directly from one of the default themes, so I think it's a pretty common pattern. Though it doesn't look like it's used elsewhere in the wporg-plugins textdomain...

Comment thread cli/class-block-plugin-checker.php Outdated
Comment thread cli/class-block-plugin-checker.php Outdated
Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
Comment thread cli/class-block-plugin-checker.php Outdated
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.

3 participants