Last active
April 28, 2020 22:05
-
-
Save pattyok/b82fe270d91712043e3ab10d964b3a66 to your computer and use it in GitHub Desktop.
WordPress Coding Standards Setup
This file contains 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
Show hidden characters
{ | |
"extends": [ | |
"plugin:@wordpress/eslint-plugin/recommended" | |
] | |
} |
This file contains 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
{ | |
"extends": [ | |
"stylelint-config-wordpress/scss" | |
] | |
} |
This file contains 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
// 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" } | |
], | |
} |
This file contains 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
## 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 | |
This file contains 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
// 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