Skip to content

Commit

Permalink
~ Added PHPCS and GitHub Action to accommodate it
Browse files Browse the repository at this point in the history
  • Loading branch information
claygriffiths committed Feb 7, 2022
1 parent f403635 commit 5395619
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/php-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PHP Lint

on: [push]

jobs:
PHPCS:
name: PHPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: composer install --dev --prefer-dist --no-progress --no-suggest
- name: PHPCS check
uses: chekalsky/phpcs-action@v1
with:
phpcs_bin_path: './vendor/bin/phpcs'
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# macOS Junk Files
.DS_Store

# Composer
/vendor

# NPM/Yarn
/node_modules

# IDE
.idea

# Transpiled/Built/Minified Files
*.js.map
*.min.js
*.css.map
*.min.css
/dist
/js/built

# Cypress
cypress/screenshots
cypress/videos

# Private Files (Personal or sensitive info to not version control)
.env
.envrc
*.log
_output
results.xml
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"wp-coding-standards/wpcs": "^2.3",
"phpcompatibility/php-compatibility": "*"
},
"scripts": {
"lint": "phpcs",
"lint:fix": "phpcbf"
}
}
263 changes: 263 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<ruleset name="Gravity Wiz Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->

<arg name="extensions" value="php,css"/>

<file>.</file>

<!-- Exclude Composer vendor directory. -->
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- Exclude NPM modules -->
<exclude-pattern>*/node_modules/*</exclude-pattern>

<!-- Handled by ESLint -->
<exclude-pattern>*.js</exclude-pattern>

<!-- Run against the PHPCompatibility ruleset -->
<rule ref="PHPCompatibility"/>
<config name="testVersion" value="5.6-"/>

<!-- Turns on the WordPress Standard -->
<rule ref="WordPress-Core">
<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase" />
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
</rule>
</ruleset>

0 comments on commit 5395619

Please sign in to comment.