phpcs: 引用的嗅探 "WordPress" 不存在
phpcs: Referenced sniff "WordPress" does not exist
我已经按照 安装了 phpcs
,并将以下内容添加到我的可视代码 settings.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 Code 在右下角显示错误:
phpcs: Referenced sniff "WordPress" does not exist
如果我 运行 phpcs -i
我收到:The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1 and PSR12
.
请问如何为 phpcs
安装 WordPress 编码标准?
更新:我遵循了@this tutorial的步骤,特别是运行ning:
./vendor/bin/phpcs --config-set installed_paths /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
(此后我收到了肯定的确认)。我将 "phpcs.standard": "WordPress",
添加到 VS Code 的 settings.json
,但是错误仍然存在,即使在重新启动 VS Code 之后也是如此。
我有 WordPress 编码标准目录@/Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
。
感谢帮助。
看起来您已经克隆了 wpcs @ WordPress 项目。
尝试将 wpcs 克隆到另一个目录,例如
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
别忘了从主题目录中删除 /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
。
我已经按照 phpcs
,并将以下内容添加到我的可视代码 settings.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 Code 在右下角显示错误:
phpcs: Referenced sniff "WordPress" does not exist
如果我 运行 phpcs -i
我收到:The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1 and PSR12
.
请问如何为 phpcs
安装 WordPress 编码标准?
更新:我遵循了@this tutorial的步骤,特别是运行ning:
./vendor/bin/phpcs --config-set installed_paths /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
(此后我收到了肯定的确认)。我将 "phpcs.standard": "WordPress",
添加到 VS Code 的 settings.json
,但是错误仍然存在,即使在重新启动 VS Code 之后也是如此。
我有 WordPress 编码标准目录@/Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
。
感谢帮助。
看起来您已经克隆了 wpcs @ WordPress 项目。 尝试将 wpcs 克隆到另一个目录,例如
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
别忘了从主题目录中删除 /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
。