wp-jazz / coding-standards
适用于所有WP Jazz项目的WordPress编码标准。
Requires
- humanmade/coding-standards: ^1.1
- humanmade/psalm-plugin-wordpress: dev-master
- phpstan/phpstan: ^1.10
- szepeviktor/phpstan-wordpress: ^1.1
- vimeo/psalm: ^4.30
This package is auto-updated.
Last update: 2024-09-16 02:40:33 UTC
README
适用于所有WP Jazz项目的WordPress编码标准。
提供一组规则集和扩展,用于
- EditorConfig — 在不同编辑器之间保持一致的编码风格。
- PHP_CodeSniffer — PHP编码检查器。
- PHPStan — PHP静态分析工具。
- Psalm — PHP静态分析工具。
这些编码标准基于并扩展了Human Made编码标准。
安装
composer require --dev wp-jazz/coding-standards
此包将安装支持的PHPCS、PHPStan和Psalm版本。
有关样板配置文件的更多信息,请参阅示例目录。
使用PHPCS
我们的PHPCS规则集扩展了PHP和WordPress的Human Made编码标准。
运行以下命令以运行标准检查
./vendor/bin/phpcs --standard=vendor/wp-jazz/coding-standards .
或者在您的phpcs.xml
中包含以下内容
<!-- Use WP Jazz Coding Standards --> <rule ref="Jazz" />
PHPCS规则集基于
并添加自定义、排除和添加以匹配我们的风格。
使用PHPStan
运行以下命令以运行静态分析
./vendor/bin/phpstan analyze -c vendor/szepeviktor/phpstan-wordpress/extension.neon .
使用phpstan/extension-installer自动找到PHPStan
composer require --dev phpstan/extension-installer
或者手动将其包含在您的phpstan.neon
中
includes: - vendor/szepeviktor/phpstan-wordpress/extension.neon
有关配置PHPStan的更多信息,请参阅Viktor Szépe的szepeviktor/phpstan-wordpress包。
使用Psalm
./vendor/bin/psalm -c vendor/wp-jazz/coding-standards/psalm.xml.dist .
使用Psalm启用插件
./vendor/bin/psalm-plugin enable humanmade/psalm-plugin-wordpress
或者手动将其包含在您的psalm.xml
中
<plugins> <pluginClass class="PsalmWordPress\Plugin" /> </plugins>
有关配置Psalm的更多信息,请参阅Human Made的humanmade/psalm-plugin-wordpress包。
使用ESLint
我们推荐使用Human Made的JavaScript编码标准,该标准使用ESLint。
npx install-peerdeps --dev @humanmade/eslint-config@latest
有关配置ESLint的更多信息,请参阅@humanmade/eslint-config包的README。
使用Stylelint
我们推荐使用Human Made的CSS和SCSS编码标准,该标准使用Stylelint。
npm install --save-dev stylelint @humanmade/stylelint-config
有关配置Stylelint的更多信息,请参阅@humanmade/stylelint包的README。