Composer: update to PHPCSExtra 1.5.0 + add two new sniffs to WordPress-Extra #2646
+8
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Composer: update to PHPCSExtra 1.5.0
PHPCSExtra 1.5.0 has been released and offers 7 new sniffs, some of which we may want to use.
Ref: https://github.com/PHPCSStandards/PHPCSExtra/releases/tag/1.5.0
WordPress-Extra: add some sniffs related to attribute formatting
It's common for code to contain PHP 8.0 attributes, even if the code still needs to run on PHP < 8.0 as attributes are cross-version compatible in the sense that they won't cause parse errors on older PHP versions but will be seen as a comment.
WordPress Core at this moment contains 193 attributes in 156 files.
https://github.com/search?q=repo%3AWordPress%2Fwordpress-develop+%23%5B&type=code
With this in mind, it makes sense to start adding some rules related to attributes formatting to WordPress-Extra.
These rules should eventually be moved to WordPress-Core after a Make post.
PHPCSExtra is starting to add some sniffs for attribute formatting. Though the set is nowhere near complete yet, these initial two sniffs should make a good addition for WPCS.
Universal.Attributes.BracketSpacingdemands no spacing on the inside of attribute brackets.While this may seem inconsistent with the otherwise space-richness of WordPressCS, if we look at prior art in WordPress Core, all attributes currently in WordPress Core comply with the "no spacing inside of the brackets" rule.
This means that if/when the rule would move to the WordPress-Core ruleset, no code churn is expected as no fixes will be needed.
Universal.Attributes.DisallowAttributeParenthesesdemands that attribute instantiations only have parentheses when parameters are passed.Again, this is 100% in line with prior art in WordPress Core.
As a side-note: both the above rules are also in line with PERCS, which means that they don't raise the barrier to entry for new contributors to WordPress.
Suggested changelog entry
Added:
WordPress-Extra: the following additional sniffs have been added to the ruleset:Universal.Attributes.BracketSpacingandUniversal.Attributes.DisallowAttributeParentheses.Changed:
PHPCSExtraversion to 1.5.0 (was 1.4.0).