VScode PHPCS 확장 오류: 참조된 Snip "WordPress-Core"가 없습니다.
VScode에 PHP CodeSniffer를 추가하고 싶습니다.
VScode에서 오류가 발생했습니다.'phpcs: Referenced sniff "WordPress-Core" does not exist'
그러나 터미널에서 다음 명령을 실행할 때:
phpcs --standard="WordPress-Core" dropdowns.php
PHP CodeSniffer는 다음 터미널 출력에서 예상대로 작동합니다.
--------------------------------------------------------------------------------
FOUND 34 ERRORS AND 17 WARNINGS AFFECTING 51 LINES
--------------------------------------------------------------------------------
15 | WARNING | [x] Array double arrow not aligned correctly; expected 10
| | space(s) between "'id'" and double arrow, but found 1.
17 | WARNING | [x] Array double arrow not aligned correctly; expected 4
| | space(s) between "'taxonomy'" and double arrow, but found
| | 1.
18 | WARNING | [x] Array double arrow not aligned correctly; expected 5
| | space(s) between "'orderby'" and double arrow, but found
| | 1.
34 | WARNING | [x] Equals sign not aligned with surrounding assignments;
| | expected 10 spaces but found 1 space
35 | WARNING | [x] Equals sign not aligned with surrounding assignments;
| | expected 7 spaces but found 1 space
36 | ERROR | [x] Short array syntax is not allowed
44 | WARNING | [x] Equals sign not aligned with surrounding assignments;
| | expected 2 spaces but found 1 space
84 | WARNING | [x] Equals sign not aligned with surrounding assignments;
| | expected 2 spaces but found 1 space
내 settings.json 파일은 다음과 같습니다.
{
"workbench.colorTheme": "Default Light+",
"window.zoomLevel": 0,
"phpcs.standard": "WordPress",
"phpcs.executablePath": "/Users/michelle/.composer/vendor/bin/phpcs",
"phpcs.enable": true,
"phpcs.showWarnings": true,
"phpcs.showSources": true,
}
내 phpcs.ruleset.xml은 다음과 같습니다.
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards">
<description>My Project's Coding Standards</description>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-Docs"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-Extra"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-Core"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPressVIPMinimum"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-VIP-Go"/>
</ruleset>
이 파일의 규칙 참조를 업데이트하여 이 오류를 해결했습니다.~/.composer/vendor/wp-coding-standards/wpcs/WordPress
절대적인 길이기도 합니다.WordPress 코딩 표준의 최종 ruleset.xml은 다음과 같습니다.
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress" namespace="WordPressCS\WordPress" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>WordPress Coding Standards</description>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-Core"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-Docs"/>
<rule ref="~/.composer/vendor/wp-coding-standards/wpcs/WordPress-Extra">
<!-- Prevent duplicate messages + deprecation notice from deprecated sniff. -->
<exclude name="WordPress.WP.TimezoneChange.timezone_change_date_default_timezone_set"/>
<exclude name="WordPress.WP.TimezoneChange.DeprecatedSniff"/>
</rule>
</ruleset>
설치된 모든 코딩 표준을 phpcs에서 사용할 수 있도록 만들어야 합니다.
phpcs --config-set installed_paths full-wpcs-path\WordPress,full-wpcs-path\WordPress-Core,full-wpcs-path\WordPress-Docs,full-wpcs-path\WordPress-Extra
https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs 의 phpcs.standard를 참조하십시오.
의 여러 버전을 사용할 가능성이 높습니다.phpcs
.
셸에서 시도:
which phpcs
만약 당신이 그런 것을 얻는다면./usr/bin/phpcs
시스템의 패키지 관리자와 함께 패키지가 설치되어 있습니다.패키지 관리자를 사용하여 관리 - 설치WordPress-Core
와 함께apt
또는brew
또는 사용 중인 항목을 삭제하거나 제거합니다(다시 시도).
결과가 나오지 않으면 Composer를 사용하여 PHPCS를 전역적으로 설치해 보십시오.확인~/.config/composer/vendor/bin
당신 안에 있습니다.PATH
.
이때 사용할 실행 파일의 경로와 위치를 알 수 있습니다.이제:
phpcs -i
그러면 설치된 표준 목록이 표시됩니다.내 말은:MySource, PEAR, PSR1, PSR12, PSR2, Squiz, Zend, PHPCompatibility, PHPCompatibilityParagonieRandomCompat, PHPCompatibilityParagonieSodiumCompat, PHPCompatibilityWP, WordPress-Core, WordPress-Docs, WordPress-Extra and WordPress
.
실행 파일의 위치와 수정 방법을 알고 있습니다(Composer withglobal
또는apt
또는brew
또는 무엇이든).올바른 것을 얻을 때까지 설치를 계속합니다.
VS Code에서 PHPCS 확장자를 사용하고 있는데 실행 파일의 전체 경로를 지정하지 않은 경우 프로젝트 경로를 확인하고 있을 수 있습니다.Composer를 설정하는 것이 얼마나 쉬운지를 고려할 때 실행 파일의 다른 복사본을 찾는 것일 수 있습니다.
올바른 실행 파일을 가리키도록 확장명을 설정합니다.이제 필요한 모든 기준을 찾을 수 있을 것입니다.
또한 여러 VS Code 확장을 실행하고 있지 않은지 확인합니다.저와 같은 경우, 새 설치로 이동할 때 필요할 것으로 생각되는 모든 확장 기능을 50개 설치합니다.일부 메타 확장에는 일반적으로 포맷터와 함께 제공되는 PHPCS 또는 "PHP의 VS Code에서 코딩해야 하는 모든 것"이 포함되어 있습니다.
- 하나의 익스텐션만 보풀 처리됩니다.
- 한 모든라가올가방니다킵리을을 가리키고 있습니다.
phpcs
실행 가능한
이 문제는 영구적으로 해결됩니다.
언급URL : https://stackoverflow.com/questions/60284975/vscode-phpcs-extension-error-referenced-sniff-wordpress-core-does-not-exist
'it-source' 카테고리의 다른 글
인증스프링 보안의 성공 담당자 (0) | 2023.06.20 |
---|---|
SQL 'where' 절의 조건 실행 순서 (0) | 2023.06.20 |
GitHub 프로젝트에서 특정 커밋을 얻는 방법 (0) | 2023.06.20 |
SQL: AVG(NULL 값 포함) (0) | 2023.06.20 |
Spring Context @Configuration에서 void 설정 방법 실행 (0) | 2023.06.20 |