Automatically apply Tighten's default code style for Laravel apps.
Duster is built on top of the following tools:
- TLint: lints Laravel and PHP code for issues not covered by other tools
- using the default
Tightenpreset
- using the default
- PHP_CodeSniffer: sniffs issues that can't be fixed automatically
- using the
Tightenpreset which is mostly PSR1 with some Tighten-specific rules
- using the
- PHP CS Fixer: adds custom rules not supported by Laravel Pint
CustomOrderedClassElementsFixerTighten-specific order of class elements
- Pint: Laravel's code style rules (with a few Tighten specific customizations)
- using the default
Laravelpreset with some Tighten-specific rules
- using the default
You can view a list of the compiled rules and examples of what they do in the style guide.
You can install the package via composer:
composer require tightenco/duster --devOptionally you can publish a GitHub Actions linting config:
./vendor/bin/duster --github-actionsTo lint everything at once:
./vendor/bin/duster
# or
./vendor/bin/duster --lintTo fix everything at once:
./vendor/bin/duster --fixTo view all available commands:
./vendor/bin/duster --helpIf you need to include or exclude files or directories for each tool you can create a duster.json config file in your project root:
{
"include": [
"bin",
"scripts",
"src",
"tests"
],
"exclude": [
"tests/fixtures"
]
}To run additional scripts as part of Duster first add them to duster.json as part of scripts separated into lint and fix.
The key is the name of the command (used with the --using flag), and the value is an array of arguments passed to Symfony\Component\Process\Process.
{
"scripts": {
"lint": {
"phpstan": ["./vendor/bin/phpstan", "analyse"]
}
}
}Duster will pick these up automatically when running either --lint or --fix.
To customize which tools Duster runs, or the order in which they are executed you can use the --using flag and supply a comma-separated list of commands:
./vendor/bin/duster --lint --using="phpstan,tlint,pint"Create a tlint.json file in your project root. Learn more in the TLint documentation.
Create a .phpcs.xml.dist file in your project root with the following:
<?xml version="1.0"?>
<ruleset>
<file>app</file>
<file>config</file>
<file>database</file>
<file>public</file>
<file>resources</file>
<file>routes</file>
<file>tests</file>
<rule ref="Tighten"/>
</ruleset>Now you can add customizations below the <rule ref="Tighten"/> line or even disable the Tighten rule to use your own ruleset. Learn more in this introductory article.
Create a .php-cs-fixer.dist.php file in your project root with the contents from Duster's .php-cs-fixer.dist.php file. Learn more in the PHP CS Fixer documentation.
Create a pint.json file in your project root, you can use Duster's pint.json file as a starting point. Learn more in the Pint documentation.
There's a GitHub Action you use to clean-up your workflows.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
- Matt Stauffer
- Tom Witkowski - much of the original idea and syntax for this was inspired by his
elbgoods/ci-test-toolspackage - All Contributors
The MIT License (MIT). Please see License File for more information.