Install phpcs with homebrew:
brew install php-code-sniffer
cd /usr/local/lib
(or wherever you want to the code sniffer rules to live)
Clone the WP rules:
git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
Add them to phpcs:
phpcs --config-set installed_paths /usr/local/lib/wpcs
Check the rules are in the installed libraries:
phpcs -i
(The list should include WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra and WordPress-VIP)
In Sublime, use Package Control (cmd + shift + p > 'Package Control: Install Package') to install:
- SublimeLinter
- sublimelinter-phpcs
Open Preferences > Package Settings > Sublime Linter > Settings and in the user settings (right hand pane) paste:
{
"linters": {
"phpcs": {
"@disable": false,
"args": [],
"excludes": [],
"standard": [
"WordPress",
"WordPress-Core",
"WordPress-Docs",
"WordPress-VIP"
],
"stdin-path": "${file}"
}
},
"paths": {
"linux": [],
"osx": [
"/usr/local/bin/phpcs"
],
"windows": []
}
}