indentno/laravel-linter

Linting for your laravel project

0.6.6 2024-05-15 12:09 UTC

This package is auto-updated.

Last update: 2024-11-15 13:23:37 UTC


README

Linting for your laravel project.

Build Status PRs Welcome psr-2

A laravel linter based on the tlint package from the folks over at Tighten.

Installation

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/"
  ]
}

Usage

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"

Configuration

The tlint.json config supports three different config keys.

Preset

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

"excluded" is an array of paths that should be excluded from the linting process.

Disabled

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/"
  ]
}

Rules

An overview of rules that needs further explanation.

ValidRouteStructure

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);

License

MIT © Indent