Build: Add file type verification for CSS and JS directories#11915
Build: Add file type verification for CSS and JS directories#11915NoumaanAhamed wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Summary
Adds automated enforcement of file type restrictions in CSS and JS source directories. Currently, it's possible to place files with incorrect extensions (e.g.,
.phpfiles) insrc/wp-includes/css/,src/wp-includes/js/,src/wp-admin/css/, andsrc/wp-admin/js/without any automated check catching it.This PR introduces two-directional enforcement:
Inward Check
Verifies that CSS directories only contain
.cssfiles and JS directories only contain.jsfiles. Gitignored build artifacts (e.g.,registry.php,*.asset.php, TinyMCE skins) are handled via an allow-list in the Grunt task only — the GitHub Actions workflow operates on a clean checkout and never encounters them.Outward Check
Verifies that
.cssand.jsfiles do not exist outside their designatedcss/andjs/directories withinwp-includes/andwp-admin/. Excluded directories that legitimately contain CSS/JS files:wp-includes/blocks/— Gutenberg block-specific assets (gitignored).wp-includes/build/— Routes/pages build system JS files (tracked).Changes
Gruntfile.jsverify:file-typesGrunt task with both inward and outward checks.verify:buildcomposite task (runs duringgrunt build).build:dev(TinyMCE skins/fonts/images,*.asset.phpmanifests,registry.php, CodeMirror/Jcrop/mediaelement/thickbox/imgAreaSelect bundled assets, SCSS color scheme sources, license files)..github/workflows/file-type-check.yml(New)findcommands (nonpm cirequired).wp-includes/orwp-admin/.Testing
npx grunt jshint:gruntnpx grunt verify:file-typeson clean codebase.phpfile insrc/wp-includes/css/.cssfile insrc/wp-admin/includes/Trac ticket: https://core.trac.wordpress.org/ticket/65279
Use of AI Tools
AI assistance: Yes
Tool(s): Gemini (Antigravity IDE)
Model(s): Claude Opus 4.6 (Thinking)
Used for: Initial code skeleton generation for the Grunt task and GitHub Actions workflow; codebase analysis to identify all gitignored vs tracked files requiring allow-listing; iterative refinement based on review feedback. Final implementation and testing were reviewed and validated by me.