As Tighten mentions on its blog
Duster is an opinionated linter and fixer for Laravel code, that takes the best of Laravel’s Pint, together with the power of PHP_CodeSniffer and PHP-CS-Fixer
Duster works on the command line, with Husky or use it's premade GitHub Action to run it in your CI pipeline
During installation & setup process I found a little issue related to Husky so here I share the solutions
composer require tightenco/duster --dev
If not you can initialize it with
git init
npm i -D husky
npm i -D lint-staged
npx husky-init
npx husky add ./.husky/pre-commit 'npx --no-install lint-staged'
npm test
command from pre-commit
file#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no-install lint-staged
npm run test # this line should be removed
php
files in package.json
file ...
"lint-staged": {
"**/*.php*": [
"vendor/bin/duster lint"
]
}
...
Instead of just lint
your codebase, you can use the Duster fix
command in order to fix the code base automatically.
Just execute
./vendor/bin/duster github-actions
It will publish a github action workflow for Duster, you can configure it and read more about Duster in the docs
Thanks for reading!
Sign up & get tips and tricks
You'll get monthly updates regarding my most recent articles and products.