Skip to content

Commit

Permalink
Merge pull request #3 from AxeWP/feat/wpcs3
Browse files Browse the repository at this point in the history
feat!: upgrade to WPCS 3.0
  • Loading branch information
justlevine committed Sep 17, 2023
2 parents b2973c1 + d2db82d commit c576c6b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.

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

## [Unreleased]
## [2.0.0-beta.1] - 2023-09-17

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.

- feat!: Bumped minimum WPCS and VIPCS versions to `3.0.0`.
- fix!: Remove unused `WordPress.CodeAnalysis.AssignmentInCondition.Found` exclusion from `WPGraphQL-Minimum`.
- feat!: Add `Generic.CodeAnalysis.UnusedFunctionParameter` and `WordPress.WP.Capabilities.Undetermined` sniffs to `WPGraphQL-Strict`. These sniffs are excluded from the `WPGraphQL-Core` standard.

## [1.0.0-beta.4] - 2023-08-17
- 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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You can use the following standard names when invoking `phpcs` to select the sni
* [`WPGraphQL`](./WPGraphQL/ruleset.xml) - complete set with all of the sniffs in the project.
- [`WPGraphQL-Minimum`](./WPGraphQL-Minimum/ruleset.xml): basic ruleset for WPGraphQL projects.
- [`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.
- [`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.
- [`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.
- [`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.
- [`WPGraphQL-Docs`](./WPGraphQL-Docs/ruleset.xml): includes sniffs for doc-blocks and inline comments.

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

- [`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.
- [`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.
- [`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.
- [`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>`.
- [`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.
8 changes: 6 additions & 2 deletions WPGraphQL-Core/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

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

</ruleset>
8 changes: 5 additions & 3 deletions WPGraphQL-Minimum/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@

<rule ref="WordPress">
<!-- Definitely should not be added back -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.Found"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>
<exclude name="WordPress.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="WordPress.PHP.DisallowShortTernary.Found"/>

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

<!-- Added back in WPGraphQL-Strict -->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments"/>
<exclude name="WordPress.WP.Capabilities.Undetermined" />

<!-- This would be a breaking change to fix in Core -->
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
</rule>
Expand Down
6 changes: 6 additions & 0 deletions WPGraphQL-Strict/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
</properties>
</rule>

<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
<severity>5</severity>
</rule>
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
<severity>5</severity>
</rule>
Expand All @@ -25,6 +28,9 @@
<rule ref="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.Capabilities.Undetermined">
<severity>5</severity>
</rule>

<!-- Additional commenting sniffs are in WPGraphQL-Docs -->
<rule ref="Squiz.Commenting.FunctionComment">
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "axepress/wp-graphql-cs",
"type": "phpcodesniffer-standard",
"description": "PHP_CodeSniffer rules (sniffs) for the WPGraphQL ecosystem.",
"version": "1.0.0-beta.3",
"version": "2.0.0-beta.1",
"keywords": [
"phpcs",
"wpcs",
Expand All @@ -25,10 +25,8 @@
],
"require": {
"php": ">=7.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
"squizlabs/php_codesniffer": "^3.7.1",
"slevomat/coding-standard": "^8.12",
"automattic/vipwpcs": "^2.3",
"automattic/vipwpcs": "^3.0",
"phpcompatibility/phpcompatibility-wp": "^2.1"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Tests for WordPress version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
-->
<config name="minimum_supported_wp_version" value="5.9"/>
<config name="minimum_wp_version" value="5.9"/>

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

0 comments on commit c576c6b

Please sign in to comment.