jakub-szajna/lint-pack
Laravel package that adds a linter command to the Artisan CLI, helping you run code style and lint checks from the command line during development and CI. Designed to integrate into typical Laravel workflows for quick, repeatable quality checks.
Installation Add the package via Composer:
composer require jakub-szajna/lint-pack
Publish the configuration (if needed):
php artisan vendor:publish --provider="JakubSzajna\LintPack\LintPackServiceProvider"
First Use Case Run the linter directly on Artisan commands:
php artisan lint
This will analyze your CLI commands for syntax errors, typos, or inconsistencies.
config/lint-pack.php for customization options (e.g., ignored commands, error thresholds).JakubSzajna\LintPack\LintPackServiceProvider for bootstrapping logic.Illuminate\Foundation\Console\Kernel—inspect how it integrates with Artisan’s event system.Pre-Command Validation Use the linter as a pre-flight check before running critical Artisan commands:
// In a custom command or middleware
if (!LintPack::validateCommand('migrate')) {
throw new \Exception('Command failed linting. Fix errors first.');
}
Integration with CI/CD Add the linter to your GitHub Actions/GitLab CI pipeline:
- name: Run Lint Pack
run: php artisan lint --fail-on-error
Custom Rules Extend the linter by creating a custom rule (if the package supports it). Example:
namespace App\Rules;
use JakubSzajna\LintPack\Rules\BaseRule;
class NoDeprecatedCommands extends BaseRule {
protected $pattern = '/artisan\s+make:controller\s+--deprecated/';
protected $message = 'Deprecated commands are not allowed.';
}
Register the rule in config/lint-pack.php under rules.
Outdated Package
Artisan::command():
if (!method_exists(\Illuminate\Foundation\Application::class, 'command')) {
// Add fallback logic
}
False Positives
php artisan {command}). Exclude these in config:
'ignored_commands' => [
'php artisan {command}',
],
Performance Overhead
artisan call may slow down development. Use selectively:
# Run only before critical commands
php artisan lint --commands=migrate,seed
'debug' => true,
storage/logs/lint-pack.log for rule execution details.php artisan lint --skip
Custom Rules Override or extend rules by publishing the package’s assets and modifying:
// config/lint-pack.php
'rules' => [
\App\Rules\NoDeprecatedCommands::class,
],
Event Listeners Hook into the linter’s events (if documented). Example:
LintPack::listen('lint.failed', function ($errors) {
// Send Slack notification
});
Command Whitelisting Whitelist commands that should bypass linting:
'whitelisted_commands' => [
'queue:work',
'tinker',
],
How can I help you explore Laravel packages today?