dsawardekar / wordpress.vim

Vim Plugin for WordPress Development
MIT License
166 stars 17 forks source link

Proper way to set phpcs to WordPress standard? #26

Closed nateroling closed 9 years ago

nateroling commented 9 years ago

Is there a better way to tell phpcs to use the WordPress standard? I ended up disabling the built-in phpcs checker and setting the option g:syntastic_wordpress_phpcs_args

This is in my ftplugin/wordpress.vim:

let g:syntastic_php_checkers = ["php", "wordpress/phpcs", "phpmd"]
let g:syntastic_wordpress_phpcs_args="--report=csv --standard=WordPress"
nateroling commented 9 years ago

Going further, is there any good way to specify a project-specific ruleset file, or have Vim find it automatically?

sudar commented 9 years ago

The latest change to the syntax checker allows you to do it.

let g:syntastic_wordpress_checkers = ['phpcs']
let g:syntastic_wordpress_phpcs_standard = "WordPress-Core" "Default standard
"Standard file name. This should be at the root of the project.
"If not found then the default standard is used
let g:syntastic_wordpress_phpcs_standard_file = "phpcs.xml"
nateroling commented 9 years ago

Great, thanks! Worked perfectly once I remembered to make sure php/phpcs wasn't enabled. My ftplugin/wordpress.vim ended up like so:

let g:syntastic_php_checkers = ["php", "phpmd"]
let g:syntastic_wordpress_phpcs_standard_file = "phpcs.xml"