Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Update PHPCS default rule set #161
The .phpcs.xml.dist rule file is detected and implemented automatically, reducing complexity for running phpcs.
The updated rules account for new wpcs sniff properties including the ability to check global prefix and i18n implementation with the correct text domain when specified.
The values have been left blank so the sniffs are generic, but the rules are in place to make it easier to get started by scaffold.
This is tangentially related to #109
This is also loosely related to #63 as updating composer scaffolds could work with this change.
@GaryJones may be able to provide additional feedback on this file change.
thanks you @GaryJones after you helped me get this on GFWA I've used it on several projects and I can't tell you the number of times it has found a minor typo in the text domain and saved me so much headache down the road. That one feature is worth the price of admission.
@jrfnl Thanks! I've added the changes you recommended.
@schlessera this may need some additional feedback from @jrfnl or @GaryJones but so far I've implemented almost everything suggested. There are a couple of comments regarding WPCS 1.0.0 but IMO we are better if this is implemented now and an issue created to update when 1.0.0 comes out with additional improvements. I'm good either way though pending release timeline for WP CLI 2.0 and WPCS 1.0.0.
@jrfnl will the current CSV method work with PHPCS 3.3.0+? If so it seams like it might be better to wait before implementing that even by reference.
Yes, the current comma-delimited string format will still work, but it will be removed in PHPCS 4.0.
For more information about this change and the new format - much more readable! -, see the PHPCS 3.3.0 release notes: https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0
Forgot to respond to this:
WPCS 1.0.0 was due to come out last week, but there's still one issue which needs to be fixed. Expect it very soon though.
All the same, for the ruleset as it is, AFAICS, no changes would be needed for WPCS 1.0.0, so you're good.
Do you mean for the actual file name
Yes, no problem.
Allowing a leading
So for the custom ruleset with a leading dot to work, the minimum PHPCS requirement would have to be set at 3.1.0.
The file loading order (as of PHPCS 3.1.1) is:
In other words, not having the leading
And beyond what @jrfnl just said, whether it's right for PHPCS 3.1[.1] to be the minimum version for scaffolded plugins is a different matter, though for new plugins I don't see much reason why the default shouldn't be 3.3.