WPCS with Visual Studio Code

Installation

The easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands:

[/crayon]

Composer

If you use Composer, you can install PHP_CodeSniffer system-wide with the following command:

[/crayon]
Make sure you have the composer bin dir in your PATH. The default value is 

, but you can check the value that you need to use by running 

.

Or alternatively, include a dependency for 

 in your 

 file. For example:

You will then be able to run PHP_CodeSniffer from the vendor bin directory:

[/crayon]

Install the WCPS:

https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

After setting the WPCS well, if we want to format the code with shortcut key according to WordPress coding standard, we’ll need to follow the instruction below –

  1. Install the PHPCBF extension.
  2. Set the phpcbf executable path.
  3. Set the shortcut key.My user settings are like –

     

    In need visit –  https://github.com/tommcfarlin/phpcs-wpcs-vscode https://wpbeaches.com/set-up-composer-and-phpcodesniffer-on-visual-studio-code-on-macos/