Skip to content

Instantly share code, notes, and snippets.

@pattyok
Last active April 28, 2020 22:05
Show Gist options
  • Save pattyok/b82fe270d91712043e3ab10d964b3a66 to your computer and use it in GitHub Desktop.
Save pattyok/b82fe270d91712043e3ab10d964b3a66 to your computer and use it in GitHub Desktop.
WordPress Coding Standards Setup
{
"extends": [
"plugin:@wordpress/eslint-plugin/recommended"
]
}
{
"extends": [
"stylelint-config-wordpress/scss"
]
}
// I apply these to every workspace so this is assigned to the User in VSCode
// You will need to install the standard in each workspace
// You should turn off the default editor autofix
// You should turn off any other formatters for these languages
{
"editor.formatOnSave": false, //turn off default editor autofix
"files.associations": {
"*.js": "javascript"
},
"prettier.disableLanguages": [
"js", "css"
], // disable prettier (if installed) when it comes to javascript
"eslint.autoFixOnSave": true,
"eslint.alwaysShowStatus": true,
"stylelint.enable": true,
"stylelint.autoFixOnSave": true,
"trailing-spaces.trimOnSave": true,
"eslint.workingDirectories": [
{ "mode": "auto" }
],
}
## In the command line at the root of your project
## Init npm and follow prompts if haven't already
npm init
## Install Stylelint and the WordPress Standard
npm install stylelint stylelint-config-wordpress --save-dev
## Install ESLint and the WordPress Standard
npm install eslint @wordpress/eslint-plugin --save-dev
## Install PHPCS and PHPCBF as well as the WordPress PHP Standard
## You will need to install Composer globally prior to this if not already done so
composer require --dev dealerdirect/phpcodesniffer-composer-installer
composer require --dev wp-coding-standards/wpcs
// Settings.json for PHPCS in VSCODE
// Recommended that this goes in the WorkSpace Settings
// NOTE:
// phpcs.composerJsonPath is looking for a path relative to the workspace
// phpcbf.executablePath wants the full path to the phpcbf file
{
"editor.formatOnSave": false,
"phpcs.enable": true,
"phpcbf.onsave": true,
"phpcs.composerJsonPath": "app/public/wp-content/themes/my-wp-theme/composer.json",
"phpcs.standard": "WordPress",
"phpcbf.documentFormattingProvider": true,
"phpcbf.debug": true,
"phpcbf.standard": "WordPress",
"phpcbf.executablePath": "/Users/User_Name/Local_Sites/my-site/app/public/wp-content/themes/my-wp-theme/vendor/bin/phpcbf"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment