我通过遵循phpcs安装了这个答案,并在VisualCodesettings.json中添加了以下内容
{
"phpcs.enable": true,
"phpcs.composerJsonPath": "wp-content/themes/wprig/composer.json",
"phpcs.standard": "WordPress",
"phpcs.executablePath": "/Users/Chris/.composer/vendor/bin/phpcs",
}但是,当我在WordPress主题中编辑一个PHP文件时,Visual会显示一个错误@右下角:
phpcs: Referenced sniff "WordPress" does not exist如果我运行phpcs -i,我会收到:The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1 and PSR12。
请问如何安装WordPress的phpcs编码标准?
Update:我遵循步骤@ 本教程,具体运行:
./vendor/bin/phpcs --config-set installed_paths /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs(在此之后,我得到了肯定的确认)。我将"phpcs.standard": "WordPress",添加到VS代码的settings.json中,但是错误仍然存在,即使在重新启动VS代码之后也是如此。
我有WordPress编码标准目录@ /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs。
帮助感激。
发布于 2020-08-23 20:45:40
看来您已经克隆了wpc@ WordPress项目。尝试将wpcs克隆到另一个dir中。
git clone -b master https://github.com/WordPress/WordPress-Coding-Standards.git /Applications/AMPPS/www/wpcs并将其路径添加到PHP_CodeSniffer配置中。
phpcs --config-set installed_paths /Applications/AMPPS/www/wpcs不要忘记从主题dir中删除/Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs。
https://stackoverflow.com/questions/60647896
复制相似问题