Skip to content

Setting up WPCS to work in Sublime Text

Gary Jones edited this page Dec 23, 2018 · 5 revisions

sublime-phpcs package

Install the sublime-phpcs package, then use the "Switch coding standard" command in the Command Palette to switch between coding standards.

SublimeLinter-phpcs

sublime-phpcs is insanely powerful, but if you'd prefer automatic linting, SublimeLinter-phpcs can do that.

  • Install PHP Sniffer and WordPress Coding Standards per the installation instructions in the readme.
  • Use Package Control to search for and install SublimeLinter then SublimeLinter-phpcs.
  • From the command palette, select Preferences: SublimeLinter Settings - User and change user.linters.phpcs.standard to the phpcs standard of your choice (e.g. WordPress, etc.).
  • If setting standard doesn't work, try setting user.linters.phpcs.args to "--standard=WordPress-Core"
  • You can also specify the standard to: "standard": "$folder/phpcs.xml.dist". That way the linter will check the root folder of your project for a phpcs.xml.dist file and read the location and usage of a standard from the file. This is useful if you are using custom ruleset.

SublimeLinter-phpcs user settings

  • You may need to restart Sublime for these settings to take effect. Error messages appear in the bottom of the editor.

SublimeLinter-phpcs linting

SublimeLinter-phpcs error

You can’t perform that action at this time.