nelson6e65/code-sniffer-helpers
最新稳定版本:v1.1.0
Composer 安装命令:
composer require nelson6e65/code-sniffer-helpers
包简介
Helpers for PHP Code Sniffer
README 文档
README
Helpers for PHP Code Sniffer.
Installation
composer require --dev nelson6e65/code-sniffer-helpers
Features
Composer scripts
phpcbf for lint-staged
A wrapper to fix your staged code (or argumented files/folders) using the PHP Code Sniffer auto-fixer.
There is a bug that does not allows you to use it directly as autofixer (squizlabs/PHP_CodeSniffer#1818). There is a workarround for using it as a composer script, but does not works for using it in a lint-staged pre-commit hook.
This helper is designed to be run with lint-staged, but you can also use it directly in your composer script.
Setup with lint-staged
Add the script to your composer.json:
{
"scripts": {
"cs:fix-filtered": ["NelsonMartell\\PhpCodeSniffer\\ComposerScripts::phpcbf"]
}
}
I used
"cs:fix-filtered"name, but you can use any script name you like.
Configure your Husky + lint-staged in your package.json
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.php": "composer cs:fix-filtered"
}
}
Example for Husky 4. Adapt it if you use Husky 5.
Usage
You can also run it directly with composer by using composer cs:fix-filtered {PATHS}. Example:
composer cs:fix-filtered src/ tests/ config/my-config-file.php
Note: Non exixtent files/directories are ignored.
Output
The output is inspired on pretty-quick output:
composer cs:fix-filtered config/ src/Example.php src/non-existent-file.php
License
Copyright (c) 2021 Nelson Martell
Read the LICENSE file for details.
统计信息
- 总下载量: 11.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-14
