Repository navigation
Add linting for PHP, patterns, and theme.json - #33
Conversation
|
@juanfra @carolinan please let me know if this would be a good start point for linting in the theme and I am happy to cycle back, fix the issues and submit this as a proper PR. |
The 60 that
With The alternative is to keep the full ruleset and add
One fix not to trust Three of the automatic fixes move inline PHP onto its own line inside a block, which changes the markup that ships:
-<p class="has-manrope-font-family has-small-font-size"><?php /* Translators: … */
-echo sprintf( esc_html__( 'Designed with %1$sWordPress%2$s', 'ipsum' ), … ); ?></p>
+<p class="has-manrope-font-family has-small-font-size">
+<?php
+/* Translators: … */
+echo sprintf( esc_html__( 'Designed with %1$sWordPress%2$s', 'ipsum' ), … );
+?>
+</p>The change is whitespace only and collapses in HTML, but it does alter rendered output, and both footer files carry trailing whitespace on the same lines. Writing those three as single-line inline PHP — Twenty Twenty-Five's style — satisfies the rule without touching the output. The 36 problems from 14 14 of them are #27. On the six CI consequence The workflow also runs on pushes to If we drop the |
Just to avoid and working without lint tools I've moved ahead and to fixing the concerns and split the lint work into three PRs to keep each review small: this one (the tooling), #40 (the pre-commit hook), and #NN (fixes for everything the linters report). They need to merge in that order, ideally together, because the Lint checks fail until #42 lands. The order and links are at the top of each description. |
…ing (package.json, lock file regenerated with npm 11, .nvmrc kept at 24.18) and moved PHPCS to PHP 7.4 to match WordPress#29.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
This change overlaps with #60 — we both bump Node and NPM to the same versions. |
carolinan
left a comment
There was a problem hiding this comment.
I'm not the best person to review this, I rarely set up these things from scratch, but I'd like us to move forward ;)
|
Some things: we should add stylelint since we have CSS in the theme (we'll see how much we can remove but we have it so we need it) and we need to fix the failures before landing this. The stylelint can happen on another PR |
|
the failures are fixed in #42 right? |
Yes that's corret @carolinan, lint issues in #33 and #40 are fixed in #42 |
Happy to add an issue and related PR for this @MaggieCabrera. But would it be easier to finish #33, #40, then #42 first? |
Match Requires PHP in style.css after WordPress#29. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This is possible now that WordPress#33 has been merged
This is possible now that WordPress#33 has been merged
This is possible now that WordPress#33 has been merged
This is possible now that WordPress#33 has been merged
* Provide style.min.css for production Using the same pattern as the TT5 theme - https://themes.trac.wordpress.org/browser/twentytwentyfive/1.5/package.json - this change adds a `style.min.css` and the tooling around it to build it. The `style.css` file would still be used any time that `SCRIPT_DEBUG` is true - which is the case for the `wp-env` setup used by Ipsum. Production setups would get the benefit of using the smaller `style.min.css` file. For sizes, `style.min.css` comes in at 3,354 bytes. Down from the 9,380 bytes of `style.css`. Here are a few quick compression numbers: - `gzip -5 style.min.css` : 1,134 bytes - `brotli -5 style.min.css` : 996 bytes - `zstd -8 style.min.css` : 1,142 bytes The original `style.css` compressed at the same rates is still larger: - `gzip -5 style.css` : 3,727 bytes - `brotli -5 style.css` : 3,426 bytes - `zstd -8 style.css` : 3,701 bytes This is an improvement across the board, and doesn't change the ability to run the theme without having to touch a build system. * Use style.css if it is newer than style.min.css * Bump to the latest versions of cssnano and postcss-cli This is possible now that #33 has been merged * Skip the generated style.min.css in Stylelint The minified stylesheet can't follow the WordPress CSS Coding Standards, so `npm run lint:css` would fail on it. The pre-commit hook passes staged files to Stylelint by name, so it also needs --allow-empty-input for a commit that only rebuilds style.min.css. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rebuild style.min.css after rebasing onto trunk style.css changed on trunk since style.min.css was built, including the palette rename in #179, so the old minified file pointed at color slugs that no longer exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Document the style.min.css build step for agents AGENTS.md still said there is no build step, and that style.css loads on the front end. CONTRIBUTING.md called style.css the only stylesheet, which stopped being true when assets/css/editor-style.css landed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fail CI when style.min.css is out of date style.min.css is committed, so nothing stopped a pull request from changing style.css without rebuilding it. The CSS job now rebuilds it and fails if the result differs from the committed copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rebuild style.min.css in the pre-commit hook Contributors no longer need to remember npm run build when they change style.css, and the CI check should rarely fail. Stylelint isn't repeated in the new task because the *.css task already runs it on style.css. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rebuild style.min.css for trunk's latest style.css Trunk changed style.css in #180 and #198 after this branch was last rebuilt, so the CI check failed on the merge with trunk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MaggieCabrera <maggie.cabrera@automattic.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: josephscott <josephscott@git.wordpress.org> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: mikachan <mikachan@git.wordpress.org> Co-authored-by: carolinan <poena@git.wordpress.org>
Note
Part 1 of 3 in the lint stack. Please merge in this order:
The Lint checks fail here until #NN merges, so the three are best merged together.
Closes #10.
What
Adds linting for the theme and runs it in CI.
composer.jsonandphpcs.xml.dist. The text domain and prefix areipsum, and the minimum WordPress and PHP versions matchstyle.css.bin/validate-theme.mjschecks:TitleandSlugare present, the slug matches the file name, header keys are ones core reads, and categories are registered by corewp:patternandwp:template-partreferences point at files that existqueryId, imageid, template-partthemetheme.jsonand the style variations against the schema for "Requires at least" (7.1), including the$schemavalue.github/workflows/lint.ymlruns PHPCS and the validator on pull requests and on pushes totrunk. PHPCS results show as annotations on the PR.enginesanddevEnginesinpackage.json,.nvmrc, andengine-strictin.npmrc.Expected failures
This PR only adds the tooling, so both jobs fail on the current theme. #NN fixes all of these.
composer format.functions.phpis clean.$schema: 14 files aren't pinned to 7.1. Point the theme.json schema at trunk #27 and #NN make the same change.queryId: 14 left over from editor exports.theme.json: 6nullborder values oncore/accordion-headingandcore/details."prefix":"Tags: "onwp:post-termsinsingle.phpandsingle-sidebar.php.Notes
package.json,package-lock.json,.gitignore, and.nvmrc. Whichever PR merges second combines them and regenerates the lock file with npm 11. Set up the development environment #16's.nvmrc(24) andengines.node(>=20) would move to the new minimums.testVersioninphpcs.xml.distshould move to7.4-.spacing.blockGapwritten as a{ top, left }object. Core supports that form, but the theme.json schema doesn't allow it yet.Testing
With PHP, Composer, and Node 24.18+ (
nvm use):Both commands should report the failures listed above.
🤖 Generated with Claude Code