dallask/all-in-one-code-checker
Composer 安装命令:
composer require dallask/all-in-one-code-checker
包简介
README 文档
README
Overview
Provides set of libraries to easily setup code quality checks based on GrumPHP for Drupal module/theme/profile. Check out this Lullabot article for more details.
Note: This library aim to help contributed/custom Drupal module/theme/profile hosted in individual git repository.
Install
-
Run
composer require dallask/all-in-one-code-checker -
Copy
grumphp.ymlin project's root directory (not Drupal root directory) withgrumphp.yml.dist -
Adjust config in
grumphp.yml -
Run
npm init(optional) -
Run
npm install dallask-all-in-one-code-checker -
If you do not see needed scripts in your package.json file, just copy them from file: ./node_modules/dallask-all-in-one-code-checker/package.json
"scripts": {
"grumphp": "./vendor/bin/grumphp run",
"phpcs:total": "./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile .",
"phpcs:current": "./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile $(git diff --name-status | grep -v \"^[RD]\" | awk '{ print $2 }')",
"phpcs:total:fix": "./vendor/bin/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile .",
"phpcs:current:fix": "./vendor/bin/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile $(git diff --name-status | grep -v \"^[RD]\" | awk '{ print $2 }')",
"stylelint:total": "stylelint '**/*.scss'",
"stylelint:current": "stylelint $(git diff --name-status | grep '\\.scss$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"stylelint:total:fix": "stylelint '**/*.scss' --fix",
"stylelint:current:fix": "stylelint --fix $(git diff --name-status | grep '\\.scss$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"prettier:total": "prettier '**/*' --check",
"prettier:current": "prettier --check $(git diff --name-status | grep '\\.scss$\\|\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"prettier:total:fix": "prettier '**/*' --write",
"prettier:current:fix": "prettier --write $(git diff --name-status | grep '\\.scss$\\|\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"eslint:total": "eslint '**/*.js'",
"eslint:current": "eslint $(git diff --name-status | grep '\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"eslint:total:fix": "eslint '**/*.js' --fix",
"eslint:current:fix": "eslint --fix $(git diff --name-status | grep '\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')"
}
That's it. Now, all tasks (listed below) run on every git commit.
Note: As part of install, GrumPHP adds
pre-commithook to repository. Existingpre-commitmight get destroyed when install/uninstall.
Features
- PHPCS with Drupal standard.
- PHP Lint
- YAML Lint
- Composer
- Composer Normalize
- JSONLint
- PHP Copy/Paste Detector (CPD)
Long list of additional checks/validators available here.
NPM Scripts
You can use next scripts to check and fix your files:
grumphp - total grumphp check according to your grumphp.yml config
PHPCS:
phpcs:total - total phpcs check for all project files
phpcs:total:fix - total phpcbf fix for all project files
phpcs:current - phpcs check for project files that were changed
phpcs:current:fix - phpcbf fix for project files that were changed
Stylelint:
stylelint:total - stylelint check for all project files
stylelint:total:fix - stylelint fix for all project files
stylelint:current - stylelint check for project files that were changed
stylelint:current:fix - stylelint fix for project files that were changed
Prettier:
prettier:total - prettier check for all project files
prettier:total:fix - prettier fix for all project files
prettier:current - prettier check for project files that were changed
prettier:current:fix - prettier fix for project files that were changed
ESLint:
eslint:total - eslint check for all project files
eslint:total:fix - eslint fix for all project files
eslint:current - eslint check for project files that were changed
eslint:current:fix - prettier fix for project files that were changed
Just run `npm run script_name` in root directory.
Composer scripts
You can use next composer scripts to check and fix your files (just copy them from the composer.json file to your project composer.json and modify options if it needed):
"scripts": {
"post-install-cmd": [
"npm install"
],
"post-update-cmd": [
"npm install"
],
"grumphp": "./vendor/bin/grumphp run",
"phpcs:total": "./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile .",
"phpcs:current": "./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile $(git diff --name-status | grep -v \"^[RD]\" | awk '{ print $2 }')",
"phpcs:total:fix": "./vendor/bin/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile .",
"phpcs:current:fix": "./vendor/bin/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile $(git diff --name-status | grep -v \"^[RD]\" | awk '{ print $2 }')",
"stylelint:total": "./node_modules/.bin/stylelint '**/*.scss'",
"stylelint:current": "./node_modules/.bin/stylelint $(git diff --name-status | grep '\\.scss$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"stylelint:total:fix": "./node_modules/.bin/stylelint '**/*.scss' --fix",
"stylelint:current:fix": "./node_modules/.bin/stylelint --fix $(git diff --name-status | grep '\\.scss$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"prettier:total": "./node_modules/.bin/prettier '**/*' --check",
"prettier:current": "./node_modules/.bin/prettier --check $(git diff --name-status | grep '\\.scss$\\|\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"prettier:total:fix": "./node_modules/.bin/prettier '**/*' --write",
"prettier:current:fix": "./node_modules/.bin/prettier --write $(git diff --name-status | grep '\\.scss$\\|\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"eslint:total": "./node_modules/.bin/eslint '**/*.js'",
"eslint:current": "./node_modules/.bin/eslint $(git diff --name-status | grep '\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')",
"eslint:total:fix": "./node_modules/.bin/eslint '**/*.js' --fix",
"eslint:current:fix": "./node_modules/.bin/eslint --fix $(git diff --name-status | grep '\\.js$' | grep -v \"^[RD]\" | awk '{ print $2 }')"
}
grumphp - total grumphp check according to your grumphp.yml config
PHPCS:
phpcs:total - total phpcs check for all project files
phpcs:total:fix - total phpcbf fix for all project files
phpcs:current - phpcs check for project files that were changed
phpcs:current:fix - phpcbf fix for project files that were changed
Stylelint:
stylelint:total - stylelint check for all project files
stylelint:total:fix - stylelint fix for all project files
stylelint:current - stylelint check for project files that were changed
stylelint:current:fix - stylelint fix for project files that were changed
Prettier:
prettier:total - prettier check for all project files
prettier:total:fix - prettier fix for all project files
prettier:current - prettier check for project files that were changed
prettier:current:fix - prettier fix for project files that were changed
ESLint:
eslint:total - eslint check for all project files
eslint:total:fix - eslint fix for all project files
eslint:current - eslint check for project files that were changed
eslint:current:fix - prettier fix for project files that were changed
Just run `composer run-script script_name` in root directory.
Usage
- To start from CLI use
./vendor/bin/grumphp run. It will check only files added bygit add. - Just follow GrumPHP documentation
dallask/all-in-one-code-checker 适用场景与选型建议
dallask/all-in-one-code-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.81k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dallask/all-in-one-code-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dallask/all-in-one-code-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2021-09-27