Skip to content

Commit

Permalink
Merge pull request #4 from justlevine/release/2.0.0-beta.2
Browse files Browse the repository at this point in the history
release: 2.0.0 beta.2
  • Loading branch information
justlevine committed Nov 5, 2023
2 parents c576c6b + 18a0713 commit 88b27c5
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 43 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ 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/).

## [2.0.0-beta.2] - 2023-11-5

This release updates the ruleset based on the latest changes to WPGraphQL core (v1.18.0). Specifically:

### WPGraphQL-Minimum
- Added `PHPCompatibility.Keywords.ForbiddenNamesAsDeclared.objectFound`.
- Moved `SlevomatCodingStandard.Classes.RequireSelfReference` from `WPGraphQL-Strict`.
- Moved `SlevomatCodingStandard.TypeHints.ReturnTypeHint.LessSpecificNativeTypeHint` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.Variables.UselessVariable` from `WPGraphQL-Extra`.

### WPGraphQL-Strict
- Moved `SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses` from `WPGraphQL-Extra`.
- Added `SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue`.
- Added `SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition`.
- Moved `SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint` from `WPGraphQL-Extra` and made explicit.

### WPGraphQL-Docs
- Added`Squiz.Commenting` subset of `WordPress-Docs`.
- Added `SlevomatCodingStandard.TypeHints.LongTypeHints`.
- Moved `SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessSuppress` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing` from `WPGraphQL-Extra`.
- Moved `SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessSuppress` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessSuppress` from `WPGraphQL-Extra` and made explicit.
- Moved `SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing` from `WPGraphQL-Extra`.

### WPGraphQL-Core
- Added `WPGraphQL-Docs` with some exceptions.

## [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.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ 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](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-Extra`](./WPGraphQL-Extra/ruleset.xml): includes all the sniffs in the `WPGraphQL-Strict` ruleset, plus additional sniffs to keep your code consistent across your project.
- [`WPGraphQL-Docs`](./WPGraphQL-Docs/ruleset.xml): includes sniffs for doc-blocks and inline comments.
* [`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). This includes the `WPGraphQL-Strict` and `WPGraphQL-Docs` ruleset, with a few sniffs disabled.

## Installation

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

<!-- Load WordPress Coding standards -->
<rule ref="WPGraphQL-Strict" >
<!-- 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" />

<!-- Depends on Squiz.Commenting.FunctionComment.MissingParamComment -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" />

<!-- Should probably be added back. -->
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing" />
</rule>

<rule ref="WPGraphQL-Docs" />
<!-- Conflicts with b/c in AbstractConnectionResolver -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />

<!-- Should probably be added back -->
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<rule />
</ruleset>
28 changes: 21 additions & 7 deletions WPGraphQL-Docs/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@

<!-- The rules below are the changes from between the original sniff or parent ruleset, and what should be applied for this Standard. -->

<rule ref="Squiz.Commenting">
<rule ref="WordPress-Docs">
<severity>5</severity>
<!-- This is an uncommon pattern. -->
<exclude name="Squiz.Commenting.LongConditionClosingComment" />
<!-- This is a fairly common pattern. -->
<exclude name="Squiz.Commenting.PostStatementComment.Found" />
<!-- Not necessary if the var is typed inline. -->
<exclude name="Squiz.Commenting.VariableComment.MissingVar" />
<!-- Conflicts with FQCN -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint" />
<!-- Conflicts with b/c in AbstractConnectionResolver -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />
</rule>
<rule ref="Squiz.Commenting.FunctionComment">
<properties>
<property name="skipIfInheritdoc" value="true" />
</properties>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessSuppress" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessSuppress" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessSuppress" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />

</ruleset>
25 changes: 0 additions & 25 deletions WPGraphQL-Extra/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,9 @@

<rule ref="SlevomatCodingStandard.ControlStructures.DisallowTrailingMultiLineTernaryOperator" />

<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="caseSensitive" value="true"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration" />
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction" />

<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />

<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<!-- WP dependencies are too loosely typed to implement this safely. -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<!-- WP dependencies are too loosely typed to implement this safely. -->
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint" />
<!-- Conflicts with Squiz.Commenting.-->
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<!-- WP dependencies are too loosely typed to implement this safely. -->
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />

<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />

</ruleset>
9 changes: 5 additions & 4 deletions WPGraphQL-Minimum/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<exclude name="WordPress.NamingConventions.ValidVariableName"/>

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

<!-- Added back in WPGraphQL-Strict -->
Expand All @@ -31,8 +30,6 @@
<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 All @@ -57,8 +54,9 @@
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition" />
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition" />
<rule ref="SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch" />
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference" />
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />

<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" />

<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
Expand All @@ -71,6 +69,9 @@
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />

<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.LessSpecificNativeTypeHint" />

<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" />
<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />

</ruleset>
12 changes: 11 additions & 1 deletion WPGraphQL-Strict/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,24 @@
<property name="enableOnObjects" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference" />

<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
<rule ref="SlevomatCodingStandard.Exceptions.DisallowNonCapturingCatch" />
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />

<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="caseSensitive" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses" />

<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint" />

<rule ref="SlevomatCodingStandard.Variables.UnusedVariable" >
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
Expand Down
2 changes: 1 addition & 1 deletion 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": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"keywords": [
"phpcs",
"wpcs",
Expand Down

0 comments on commit 88b27c5

Please sign in to comment.