Linting for your laravel project.
A laravel linter based on the tlint package from the folks over at Tighten.
Install the package as a dev dependency:
composer require indentno/laravel-linter --dev
Create a config (tlint.json
), at the root of your repository, with the following contents:
{
"preset": "Indent\\LaravelLinter\\Presets\\IndentPreset",
"excluded": [
"tests/",
"database/"
]
}
Run the linter with all linters in the preset:
./vendor/bin/tlint
Run the linter against a single file or directory:
./vendor/bin/tlint lint app/Http/Controllers/PageController.php
./vendor/bin/tlint lint app
Lint the project with a single linter:
./vendor/bin/tlint --only="NoCompact"
The tlint.json
config supports three different config keys.
The "preset" defines which preset that should be used for linting the project. A preset is basicly just a set of linters, or rules, that the project should adhere to.
"excluded" is an array of paths that should be excluded from the linting process.
The "disabled" key can be used to disable a set of linters from being run in your project.
{
"preset": "Indent\\LaravelLinter\\Presets\\IndentPreset",
"disabled": [
"NoCompact",
"UseConfigOverEnv"
],
"excluded": [
"tests/",
"database/"
]
}
An overview of rules that needs further explanation.
Routes should be structured the way we prefer.
Examples
Route::get('articles', [ArticleController::class, 'index'])->name('article.index');
Route::patch('page/{id}', [PageController::class, 'update'])
->name('admin.page.update')
->middleware(CanUpdatePage::class);
MIT © Indent