Skip to content

Instantly share code, notes, and snippets.

@jshakes
Last active September 14, 2018 03:52
Show Gist options
  • Save jshakes/7d7e94226fc1ed94a0273dae412ed15f to your computer and use it in GitHub Desktop.
Save jshakes/7d7e94226fc1ed94a0273dae412ed15f to your computer and use it in GitHub Desktop.
Installing Wordpress PHP linting in SublimeText

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": []
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment