Opened 3 years ago
Last modified 5 weeks ago
#56794 new enhancement
Add linting for `gutenberg_*` functions
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | has-patch 2nd-opinion |
| 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 (10)
#2
in reply to:
↑ 1
;
follow-up:
↓ 3
@
3 years ago
Replying to jrf:
We could possibly enable the WPCS
PrefixAllGlobalssniff 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
@
3 years ago
Replying to Bernhard Reiter:
Replying to jrf:
We could possibly enable the WPCS
PrefixAllGlobalssniff 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 thegutenberg_prefix everywhere. Can thePrefixAllGlobalssniff 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.
3 years ago
#5
@
3 years 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.
3 years ago
#7
@
3 years ago
There's also an issue in the Gutenberg repo discussing this: https://github.com/WordPress/gutenberg/issues/44151
This ticket was mentioned in PR #10554 on WordPress/wordpress-develop by @desrosj.
6 weeks ago
#8
- Keywords has-patch added
This adds a Grunt task that scans PHP files in the src directory for function gutenberg_ to help prevent scenarios where one is accidentally merged from the Gutenberg plugin.
Trac ticket: Core-56794
#9
@
6 weeks ago
- Keywords 2nd-opinion added
- Type changed from defect (bug) to enhancement
What about something in Grunt and the grunt precommit task like this pull request?
@ellatrix commented on PR #10554:
5 weeks ago
#10
Sounds good to me :)
We could possibly enable the WPCS
PrefixAllGlobalssniff for select directories in Core ?That should catch these issues.