Skip to content

Commit c576c6b

Browse files
authored
Merge pull request #3 from AxeWP/feat/wpcs3
feat!: upgrade to WPCS 3.0
2 parents b2973c1 + d2db82d commit c576c6b

File tree

7 files changed

+29
-13
lines changed

7 files changed

+29
-13
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
66

7-
## [Unreleased]
7+
## [2.0.0-beta.1] - 2023-09-17
8+
9+
This release requires WPCS 3.0.0 or higher. Please read the [WordPressCS 3.0 upgrade guide](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers) for instructions on how to update your local rulesets and code annotations.
10+
11+
- feat!: Bumped minimum WPCS and VIPCS versions to `3.0.0`.
12+
- fix!: Remove unused `WordPress.CodeAnalysis.AssignmentInCondition.Found` exclusion from `WPGraphQL-Minimum`.
13+
- feat!: Add `Generic.CodeAnalysis.UnusedFunctionParameter` and `WordPress.WP.Capabilities.Undetermined` sniffs to `WPGraphQL-Strict`. These sniffs are excluded from the `WPGraphQL-Core` standard.
814

915
## [1.0.0-beta.4] - 2023-08-17
1016
- feat!: Updated `WPGraphQL-Minimum` and `WPGraphQL-Strict` based on the latest changes to WPGraphQL core. (See https://github.com/wp-graphql/wp-graphql/compare/release/v1.14.10...develop#diff-05ae9cddcaec1e845771a7db224961439f83ef5939ec67d3a48744cb34d7e58b)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ You can use the following standard names when invoking `phpcs` to select the sni
2525
* [`WPGraphQL`](./WPGraphQL/ruleset.xml) - complete set with all of the sniffs in the project.
2626
- [`WPGraphQL-Minimum`](./WPGraphQL-Minimum/ruleset.xml): basic ruleset for WPGraphQL projects.
2727
- [`WPGraphQL-Strict`](./WPGraphQL-Strict/ruleset.xml): includes all the sniffs in the `WPGraphQL-Minimum` ruleset, plus additional functional sniffs to help you produce enterprise-ready code.
28-
- [`WPGraphQL-Core`](./WPGraphQL-Core/ruleset.xml): includes all the sniffs currently used by the WPGraphQL core project. Currently is the same as the `WPGraphQL-Strict` ruleset, with a few sniffs disabled.
28+
- [`WPGraphQL-Core`](./WPGraphQL-Core/ruleset.xml): includes all the sniffs currently used by the [WPGraphQL core project](https://github.com/wp-graphql/wp-graphql/blob/develop/phpcs.xml.dist). Currently this is the same as the `WPGraphQL-Strict` ruleset, with a few sniffs disabled.
2929
- [`WPGraphQL-Extra`](./WPGraphQL-Extra/ruleset.xml): includes all the sniffs in the `WPGraphQL-Strict` ruleset, plus additional formatting sniffs to keep your code looks consistent across your project.
3030
- [`WPGraphQL-Docs`](./WPGraphQL-Docs/ruleset.xml): includes sniffs for doc-blocks and inline comments.
3131

@@ -52,6 +52,6 @@ The best way to use these sniffs in your project is to create a [local configura
5252
In this file, you will want to configure the following:
5353

5454
- [`testVersion`](./phpcs.xml.dist.example#L33) - The minimum PHP version you want to test against. This should be the lowest version of PHP that you want to support. While WPGraphQL officially supports PHP 7.1+, we recommend testing against PHP 7.3 (the current lowest version actively [tested against](https://github.com/wp-graphql/wp-graphql/blob/develop/.github/workflows/testing-integration.yml)) or higher.
55-
- [`minimum_supported_wp_version`](./phpcs.xml.dist.example#L43) - The minimum WordPress version you want to test against. This should be the lowest version of WordPress that you want to support. While WPGraphQL officially supports WordPress 5.0+, we recommend testing against WordPress 5.6 (the current lowest version actively [tested against](https://github.com/wp-graphql/wp-graphql/blob/develop/.github/workflows/testing-integration.yml)) or higher.
55+
- [`minimum_wp_version`](./phpcs.xml.dist.example#L43) - The minimum WordPress version you want to test against. This should be the lowest version of WordPress that you want to support. While WPGraphQL officially supports WordPress 5.0+, we recommend testing against WordPress 5.6 (the current lowest version actively [tested against](https://github.com/wp-graphql/wp-graphql/blob/develop/.github/workflows/testing-integration.yml)) or higher.
5656
- [`WordPress.WP.I18n.text_domain`](./phpcs.xml.dist.example#L63) - The text domain used in your project. This is used by the `WordPress.WP.I18n` sniff to check that all translatable strings are assigned to a text domain. We recommend using the format `wp-graphql-<project-name>`.
5757
- [`WordPress.NamingConventions.PrefixAllGlobals`](./phpcs.xml.dist.example#L57) - The list of prefixes used in your project. This is used by the `WordPress.NamingConventions.PrefixAllGlobals` sniff to check that all global functions, classes, constants, and variables are prefixed.

WPGraphQL-Core/ruleset.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66

77
<!-- Load WordPress Coding standards -->
88
<rule ref="WPGraphQL-Strict" >
9-
<!-- This would be a breaking change to fix in Core -->
10-
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
119
<!-- Conflicts with b/c in AbstractConnectionResolver -->
1210
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />
11+
<!-- This would be a breaking change to fix in Core -->
12+
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
13+
<!-- Most capabilities are referenced via variable -->
14+
<exclude name="WordPress.WP.Capabilities.Undetermined" />
15+
<!-- Most would require breaking changes to fix in core. Tracking: https://github.com/wp-graphql/wp-graphql/issues/2925 -->
16+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
1317
</rule>
1418

1519
</ruleset>

WPGraphQL-Minimum/ruleset.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@
1616

1717
<rule ref="WordPress">
1818
<!-- Definitely should not be added back -->
19-
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
20-
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.Found"/>
19+
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
20+
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>
2121
<exclude name="WordPress.Files.FileName"/>
2222
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
23-
<exclude name="WordPress.PHP.DisallowShortTernary.Found"/>
2423

2524
<!-- Should probably not be added back -->
2625
<exclude name="PHPCompatibility.Keywords.ForbiddenNamesAsDeclared.objectFound"/>
2726
<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores"/>
2827

2928
<!-- Added back in WPGraphQL-Strict -->
29+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
3030
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
3131
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
3232
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments"/>
33+
<exclude name="WordPress.WP.Capabilities.Undetermined" />
34+
3335
<!-- This would be a breaking change to fix in Core -->
3436
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
3537
</rule>

WPGraphQL-Strict/ruleset.xml

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
</properties>
1414
</rule>
1515

16+
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
17+
<severity>5</severity>
18+
</rule>
1619
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
1720
<severity>5</severity>
1821
</rule>
@@ -25,6 +28,9 @@
2528
<rule ref="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid">
2629
<severity>5</severity>
2730
</rule>
31+
<rule ref="WordPress.WP.Capabilities.Undetermined">
32+
<severity>5</severity>
33+
</rule>
2834

2935
<!-- Additional commenting sniffs are in WPGraphQL-Docs -->
3036
<rule ref="Squiz.Commenting.FunctionComment">

composer.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "axepress/wp-graphql-cs",
33
"type": "phpcodesniffer-standard",
44
"description": "PHP_CodeSniffer rules (sniffs) for the WPGraphQL ecosystem.",
5-
"version": "1.0.0-beta.3",
5+
"version": "2.0.0-beta.1",
66
"keywords": [
77
"phpcs",
88
"wpcs",
@@ -25,10 +25,8 @@
2525
],
2626
"require": {
2727
"php": ">=7.2",
28-
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
29-
"squizlabs/php_codesniffer": "^3.7.1",
3028
"slevomat/coding-standard": "^8.12",
31-
"automattic/vipwpcs": "^2.3",
29+
"automattic/vipwpcs": "^3.0",
3230
"phpcompatibility/phpcompatibility-wp": "^2.1"
3331
},
3432
"require-dev": {

phpcs.xml.dist.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
Tests for WordPress version compatibility.
4444
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
4545
-->
46-
<config name="minimum_supported_wp_version" value="5.9"/>
46+
<config name="minimum_wp_version" value="5.9"/>
4747

4848
<!-- Rules: WPGraphQL Coding Standards -->
4949
<!-- https://github.com/AxeWP/WPGraphQL-Coding-Standards/WPGraphQL/ruleset.xml -->

0 commit comments

Comments
 (0)