mirror of
https://github.com/WordPress/WordPress-Coding-Standards.git
synced 2025-08-30 03:11:24 +08:00
Page:
Setting up WordPressCS to work in Sublime Text
Pages
Customizable sniff properties
Escaping a WP_Error object
Fixing errors for input data
Home
How to use WordPressCS with Eclipse and XAMPP
Ignoring Parts of a File
Project Timeline
Running in GitHub Actions
Running in Travis
Sanitizing array input data
Setting up WordPressCS to work in Atom
Setting up WordPressCS to work in Sublime Text
Upgrade Guide to WordPressCS 2.0.0 for Developers of external standards
Upgrade Guide to WordPressCS 3.0.0 for Developers of external standards
Upgrade Guide to WordPressCS 3.0.0 for ruleset maintainers
No results
1
Setting up WordPressCS to work in Sublime Text
jrfnl edited this page 2023-08-20 05:44:52 +02:00
Table of Contents
Functioning in 2023
As of writing this, the only working approach is this, which uses sublime-phpcs
. The article linked has a full, step by step instruction with possible issue resolutions as well.
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 changeuser.linters.phpcs.standard
to the phpcs standard of your choice (e.g.WordPress
, etc.). - If setting
standard
doesn't work, try settinguser.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 aphpcs.xml.dist
file and read the location and usage of a standard from the file. This is useful if you are using custom ruleset.
- You can specify multiple standards, show violation codes, include runtime args for something like PHPCompatibility, and choose which directories to ignore:
// SublimeLinter Settings - User
{
"linters": {
"phpcs": {
"args": "--standard=WordPress-Extra,WordPress-Docs,PHPCompatibilityWP --runtime-set testVersion 7.2- -s",
"excludes": "vendor/"
}
}
}
- You may need to restart Sublime for these settings to take effect. Error messages appear in the bottom of the editor.
You can also choose to Show All Errors (from the Command Pallette) - when you select a line, the list scrolls to the correct line:
IDE configuration
Fixing violations
Ignoring violations
Running in CI
For ruleset maintainers
For developers
Project History