Make WordPress Core

Opened 2 years ago

Last modified 15 months ago

#56794 new defect (bug)

Add linting for `gutenberg_*` functions

Reported by: desrosj's profile desrosj Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: coding-standards Cc:

Description

When Gutenberg functionality is deemed ready and merged into Core, all gutenberg prefixes should be replaced with wp_* or other more context appropriate ones.

There should be some type of automated process that attempts to detect occurrences that accidentally make their way in.

Change History (7)

#1 follow-up: @jrf
2 years ago

We could possibly enable the WPCS PrefixAllGlobals sniff for select directories in Core ?

That should catch these issues.

#2 in reply to: ↑ 1 ; follow-up: @Bernhard Reiter
22 months ago

Replying to jrf:

We could possibly enable the WPCS PrefixAllGlobals sniff for select directories in Core ?

I thought that only supported forcing the presence of a prefix (e.g. for a plugin)? We don't really want to mandate that every function in a given directory is prefixed with wp_ (we do allow a few without that in Gutenberg blocks) but rather want to ban the gutenberg_ prefix everywhere. Can the PrefixAllGlobals sniff do that?

#3 in reply to: ↑ 2 @jrf
22 months ago

Replying to Bernhard Reiter:

Replying to jrf:

We could possibly enable the WPCS PrefixAllGlobals sniff for select directories in Core ?

I thought that only supported forcing the presence of a prefix (e.g. for a plugin)? We don't really want to mandate that every function in a given directory is prefixed with wp_ (we do allow a few without that in Gutenberg blocks) but rather want to ban the gutenberg_ prefix everywhere. Can the PrefixAllGlobals sniff do that?

Correct. My response was based on @spacedmonkey mentioning enforcing the wp_ prefix and for that the sniff could be turned on and the sniff would then flag all code in the global namespace not prefixed with wp_ within the target directories (may need a minor change to make the sniff suitable for Core).

rather want to ban the gutenberg_ prefix everywhere.

Well, you wouldn't be able to do that in the normal CI PHPCS run, but you would be able to do that by using the sniff with some arbitrary prefix locally. Running PHPCS like that would give the person preparing the patch a checklist to use/verify.

This ticket was mentioned in Slack in #core by costdev. View the logs.


19 months ago

#5 @costdev
19 months ago

  • Milestone changed from 6.2 to Awaiting Review

This ticket was discussed during the bug scrub. As this ticket still needs discussion about how to proceed, I'm moving this ticket to Awaiting Review.

Additional props: @hellofromTonya

This ticket was mentioned in Slack in #core by bernhardreiter. View the logs.


15 months ago

#7 @Bernhard Reiter
15 months ago

There's also an issue in the Gutenberg repo discussing this: https://github.com/WordPress/gutenberg/issues/44151

Note: See TracTickets for help on using tickets.