【问题标题】:phpcs: Referenced sniff "WordPress" does not existphpcs:引用的嗅探“WordPress”不存在
【发布时间】:2020-06-24 03:17:57
【问题描述】:

我已经通过关注this answer 安装了phpcs,并将以下内容添加到我的Visual Code 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的步骤,具体运行:

./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

帮助表示赞赏。

【问题讨论】:

  • 你搞定了吗?
  • 还没有@AndreVitorio。

标签: phpcs


【解决方案1】:

看起来你已经克隆了 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-02
    • 2017-03-20
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 2020-06-25
    相关资源
    最近更新 更多