GLOBAL: PHPCS, PHPCBF, and WPCS Coding Standards with VS Code

# Download using curl

curl --url https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar --output /usr/local/bin/phpcs
curl --url https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar --output /usr/local/bin/phpcbfCode language: JavaScript (javascript)

# Give the execution permissions

sudo chmod +x /usr/local/bin/phpcs
sudo chmod +x /usr/local/bin/phpcbf

# Install WordPress Coding Standards

composer global require "wp-coding-standards/wpcs"Code language: PHP (php)

# Apply the new coding standards

phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcsCode language: JavaScript (javascript)

# Update the default standard

phpcs --config-set default_standard WordPressCode language: JavaScript (javascript)

# Install the VS Code Extension

PHP Sniffer & Beautifier: https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpsab

# Add these settings to the settings.json file of VS Code

  // PHPCS & PHPCBF
    "phpsab.fixerEnable": true,
    "phpsab.snifferEnable": true,
    "phpsab.executablePathCS": "/usr/local/bin/phpcs",
    "phpsab.executablePathCBF": "/usr/local/bin/phpcbf",
    "phpsab.standard": "WordPress",
    "phpsab.snifferMode": "onType",
    "phpsab.snifferTypeDelay": 250,Code language: JSON / JSON with Comments (json)


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.