Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wpscholar committed Jan 7, 2019
0 parents commit 3cd8eb1
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
76 changes: 76 additions & 0 deletions Bluehost/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0"?>
<ruleset name="Bluehost">
<description>The Bluehost PHP Code Sniffer standard.</description>

<config name="installed_paths" value="../../phpcompatibility/php-compatibility,../../wp-coding-standards/wpcs"/>

<exclude-pattern>*/phpunit.xml*</exclude-pattern>
<exclude-pattern>*/languages/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>

<!-- Third-party code -->
<exclude-pattern>*/bower-components/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- Ensure certain file types aren't sniffed -->
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>

<!-- Don't worry about files that don't contain any code -->
<rule ref="Internal.NoCodeFound">
<severity>0</severity>
</rule>

<!-- Ignore mixed line-endings warnings -->
<rule ref="Internal.LineEndings.Mixed">
<severity>0</severity>
</rule>

<!-- Internal exceptions (often occur on minified files) -->
<rule ref="Internal.Tokenizer.Exception">
<severity>0</severity>
</rule>

<!-- For CI, don't fail on warnings -->
<config name="ignore_warnings_on_exit" value="1"/>

<!-- Enforce doc standards -->
<rule ref="WordPress-Docs">
<!-- Don't worry about capitolizing long lines -->
<exclude name="Generic.Commenting.DocComment.LongNotCapital"/>
</rule>

<rule ref="WordPress-Extra">
<!-- Forget about file names -->
<exclude name="WordPress.Files.FileName"/>

<!-- Allow same line control structures e.g. if ( true ) { echo 1; } -->
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>

<!-- Don't require punctuation after inline comments -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>

<!-- Allow empty catch statements -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>

<!-- Comment punctuation doesn't matter -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
</rule>

<!-- Sets the minimum supported WP version to 4.7, which is over a year old. -->
<config name="minimum_supported_wp_version" value="4.7"/>

<!-- Make missing translator comment a warning. -->
<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
<type>warning</type>
</rule>

<!-- Sometimes we need to override globals -->
<rule ref="WordPress.WP.GlobalVariablesOverride.OverrideProhibited">
<type>warning</type>
</rule>

<!-- Loads the PHP Compatibility ruleset. -->
<rule ref="PHPCompatibility"/>
</ruleset>
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "bluehost/wp-php-standards",
"description": "PHP Code Sniffer Standards for Bluehost WordPress projects.",
"type": "phpcs-standards",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Micah Wood",
"email": "micah@wpscholar.com"
}
],
"require": {
"squizlabs/php_codesniffer": "@stable",
"phpcompatibility/php-compatibility": "@stable",
"wp-coding-standards/wpcs": "@stable",
"wpscholar/phpcs-standards-installer": "@stable"
}
}
28 changes: 28 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# WordPress PHP Standards

PHP Code Sniffer Standards for Bluehost WordPress projects.

## Installation

Run `composer require bluehost/wp-php-standards` from your project root.

Add any extra PHP Code Sniffer configuration options to your composer.json file as follows and then run `composer install`:

```json
"extra": {
"phpcs-config": {
"default_standard": "Bluehost",
"testVersion": "5.2-"
}
}
```

## IDE Integration
Some IDE integrations of PHPCS will fail to register your ruleset since it doesn't live in your project root. In order to rectify this, place phpcs.xml at your project root:

```xml
<?xml version="1.0"?>
<ruleset name="Project Rules">
<rule ref="Bluehost" />
</ruleset>
```

0 comments on commit 3cd8eb1

Please sign in to comment.