Created
May 1, 2021 06:57
-
-
Save developer-anuragsingh/f648d8bfdb019b7e9f9992e4c6ef7b8a to your computer and use it in GitHub Desktop.
WordPress Coding Standards in VSCode Macbook M1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ref - https://www.edmundcwm.com/setting-up-wordpress-coding-standards-in-vs-code/ | |
1. Install PHP CodeSniffer (PHPCS) | |
composer global require "squizlabs/php_codesniffer=*" | |
2. Create a Utilities folder | |
mkdir Utilities | |
cd Utilities | |
3. Download WPCS | |
git clone -b master https://github.com/WordPress/WordPress-Coding-Standards.git wpcs | |
4. Add WPCS to PHPCS | |
~/.composer/vendor/bin/phpcs --config-set installed_paths ~/Developer/wp/Utilities/wpcs | |
5. Check to ensure WPCS is added | |
~/.composer/vendor/bin/phpcs -i | |
6. If WPCS is added correctly, we should see the following output: | |
The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core | |
7. Configuring VSCode | |
i. Install phpcs (Ioannis Kappas) and phpcbf (Per Soderlind) extensions | |
ii. Configure settings.json | |
// | |
"phpcs.enable": true, | |
"phpcs.executablePath": "/path/to/composer/vendor/bin/phpcs", | |
"phpcs.standard": "WordPress" | |
"phpcbf.enable": true, | |
"phpcbf.documentFormattingProvider": true, | |
"phpcbf.onsave": true, | |
"phpcbf.executablePath": "/path/to/composer/vendor/bin/phpcbf", | |
"phpcbf.standard": "WordPress", | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment