- How do I install and run tlint in a Laravel project?
- Install via Composer with `composer require tightenco/tlint`. Run checks with `php artisan tlint:check` or auto-fix issues using `php artisan tlint:fix`. For dry runs, use `--fix-dry-run` to preview changes before applying them.
- Does tlint work with Laravel 10 or 11? What about older versions?
- Tlint officially supports Laravel 8+ and is tested up to Laravel 13.x. However, versions before 7.0.0 supported PHP 7.3/7.4 and older Laravel releases, so check your project’s compatibility if using pre-7.0.0.
- Can tlint auto-fix Laravel-specific issues like Blade directives or Facade imports?
- Yes, tlint includes formatters like `SpaceAfterBladeDirectives` and linters like `FullyQualifiedFacades` to auto-fix common Laravel patterns. Configure these in `tlint.json` under the `formatters` or `linters` sections.
- How do I exclude certain files or directories from linting?
- Use the `exclude` key in your `tlint.json` config to specify paths or file patterns. For example, `"exclude": ["tests/*", "vendor/*"]` skips test and vendor files during linting.
- Will tlint conflict with PHPStan or Psalm in my CI pipeline?
- Tlint focuses on style and convention enforcement (e.g., Facade usage, Blade formatting), while PHPStan/Psalm handle static analysis. Overlaps like `NoDump` (for `dd()`) may require prioritization—run tlint first if you want to gate style issues separately.
- How can I customize tlint to match my team’s coding standards?
- Extend the default `tighten` preset by adding custom linters/formatters in `tlint.json`. For example, include `"linters": ["NoJsonDirective", "CustomLaravelRule"]` to enforce project-specific rules.
- Does tlint integrate with Git hooks or CI/CD tools like GitHub Actions?
- Yes, tlint supports Git hooks (e.g., pre-commit) via `php artisan tlint:check --fix`. For CI/CD, use exit codes (0 = no issues, 1 = errors) in GitHub Actions or GitLab CI. Example: `run: php artisan tlint:check` in your workflow.
- How do I handle false positives or suppress specific warnings?
- Use the `ignore` key in `tlint.json` to suppress warnings for specific files or rules. For example, `"ignore": ["app/Helpers/old_code.php", "NoDump"]` skips linting for that file or rule entirely.
- What’s the performance impact of running tlint in a large Laravel codebase?
- Tlint can be resource-intensive for large projects. Mitigate this by linting specific paths (e.g., `"paths": ["app", "routes"]`) or running it in parallel with tools like `php-parallel-lint`. Cache results in CI if repeat runs are common.
- Are there alternatives to tlint for Laravel-specific linting?
- Alternatives include `laravel-pint` (for formatting) or custom PHP_CodeSniffer rules. However, tlint is uniquely tailored for Laravel conventions (e.g., Facades, Blade) and offers auto-fixing, making it a more comprehensive solution for teams adopting Tighten’s standards.