Skip to content

Instantly share code, notes, and snippets.

@alokstha1
Last active March 21, 2018 06:26
Show Gist options
  • Save alokstha1/ac084939274cab0ab4a49e65e46da1a5 to your computer and use it in GitHub Desktop.
Save alokstha1/ac084939274cab0ab4a49e65e46da1a5 to your computer and use it in GitHub Desktop.
WPCS with php composer for WordPress themes and plugins in your project
{
"repositories": [{
"type" : "package",
"package" : {
"name" : "wpcs",
"version" : "0.11.0",
"type" : "wpcs",
"source" : {
"url" : "[email protected]:WordPress-Coding-Standards/WordPress-Coding-Standards.git",
"type" : "git",
"reference" : "master"
}
}
}],
"require": {
"wpcs":"*",
"squizlabs/php_codesniffer": "2.9"
},
"extra": {
"installer-paths": {
"{$name}/" : ["type:wpcs"]
}
},
"scripts" : {
"post-install-cmd": [
"@phpcs-configset"
],
"post-update-cmd": [
"@phpcs-configset"
],
"phpcs-configset" : [
"\"vendor/bin/phpcs\" --config-set installed_paths vendor/wpcs"
],
"run-phpcs": [
"@run-phpcs:stack",
"@run-phpcs:theme"
],
"run-phpcs:stack": [
"\"vendor/bin/phpcs\" --standard=WordPress-Core --exclude=WordPress.Files.FileName --extensions=php -p -n -s --colors ."
],
"run-phpcs:theme": [
"\"vendor/bin/phpcs\" --standard=WordPress-Core --exclude=WordPress.Files.FileName --extensions=php -p -n -s --colors ./wp-content/themes/"
],
"run-phpcs:plugin": [
"\"vendor/bin/phpcs\" --standard=WordPress-Core --exclude=WordPress.Files.FileName --extensions=php -p -n -s --colors ./wp-content/plugins/"
],
"fix-phpcs": [
"@fix-phpcs:stack",
"@fix-phpcs:theme"
],
"fix-phpcs:stack": [
"\"vendor/bin/phpcbf\" --standard=WordPress-Core --extensions=php -n ."
],
"fix-phpcs:theme": [
"\"vendor/bin/phpcbf\" --standard=WordPress-Core --extensions=php -n ./wp-content/themes/"
],
"fix-phpcs:plugin": [
"\"vendor/bin/phpcbf\" --standard=WordPress-Core --extensions=php -n ./wp-content/plugins/"
]
}
}

run $ composer update
$ composer phpcs-configset
$ composer run-phpcs:theme (for themes) or run-phpcs:plugin (for plugins)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment