{"id":13563364,"url":"https://github.com/tighten/tlint","last_synced_at":"2025-05-14T05:10:48.685Z","repository":{"id":37747263,"uuid":"89003511","full_name":"tighten/tlint","owner":"tighten","description":"Tighten linter for Laravel conventions.","archived":false,"fork":false,"pushed_at":"2025-03-21T18:27:39.000Z","size":1454,"stargazers_count":529,"open_issues_count":2,"forks_count":32,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-05-06T10:47:14.823Z","etag":null,"topics":["code-style","conventions","laravel","linter","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tighten.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-04-21T16:28:51.000Z","updated_at":"2025-04-25T07:02:48.000Z","dependencies_parsed_at":"2024-01-18T05:18:21.642Z","dependency_job_id":"07b0bf17-3bfe-4a67-8059-8001d91281f1","html_url":"https://github.com/tighten/tlint","commit_stats":{"total_commits":645,"total_committers":31,"mean_commits":"20.806451612903224","dds":0.6310077519379844,"last_synced_commit":"b0175af6bf6722d693843d23db313561c1f28f4c"},"previous_names":["tightenco/tlint"],"tags_count":91,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tighten%2Ftlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tighten%2Ftlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tighten%2Ftlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tighten%2Ftlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tighten","download_url":"https://codeload.github.com/tighten/tlint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253350142,"owners_count":21894834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-style","conventions","laravel","linter","php"],"created_at":"2024-08-01T13:01:18.445Z","updated_at":"2025-05-14T05:10:48.480Z","avatar_url":"https://github.com/tighten.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"![TLint Logo](https://raw.githubusercontent.com/tighten/tlint/master/tlint-banner.png)\n\n\u003chr\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tightenco/tlint.svg?style=flat-square)](https://packagist.org/packages/tightenco/tlint)\n\n## Install (Requires PHP 8.1+)\n\n\u003e **Note**\n\u003e TLint is intended to work with the tools included in [Duster](https://github.com/tighten/duster). To receive the best coverage we recommend using Duster to install and configure TLint.\n\n```bash\n# Include in project\ncomposer require tightenco/tlint --dev\n\n# Include globally\ncomposer global require tightenco/tlint\n```\n\n## Upgrade\n\n```bash\n# Upgrade in project\ncomposer update tightenco/tlint\n\n#Upgrade globally\ncomposer global update tightenco/tlint\n```\n\n### Upgrading from 8.x to 9.x\n\nTLint 9 requires PHP \u003e= 8.1.\n\n`tformat.json` has been dropped in favor of a single `tlint.json` file.\n\nNow linting the following files and directories:\n\n-   `public/`\n-   `bootstrap/`\n-   `server.php`\n-   `app/Http/Middleware/RedirectIfAuthenticated.php`\n-   `Exceptions/Handler.php`\n-   `app/Http/Controllers/Auth/`\n-   `app/Http/Kernel.php`\n\nTo continue excluding these files and directories add them to your `tlint.json` file under `excluded`.\n\n### Upgrading from 7.x to 8.x\n\nA significant number of formatters were added between the 7.x and 8.x releases.\nIf you want to roll these out gradually or disable them altogether, you can use the `disabled` setting in your `tlint.json` config.\n\n### Upgrading from 6.x to 7.x\n\nTLint focuses on linting and formatting issues other tools are not able to catch.\nThe `7.x` release removes lints and formatters covered by tools in [Duster](https://github.com/tighten/duster). If you need to add these back you can grab them from an earlier version of TLint and follow the [Custom Configuration](#custom-configuration--presets) documentation.\n\n## What Is It?\n\nThis is an opinionated code linter (with growing support for auto-formatting!) for Tighten flavored code conventions for Laravel and PHP.\n\nFor example, Laravel has many available ways to pass variables from a controller to a view:\n\n\u003e **A)**\n\n```php\n$value = 'Hello, World!';\n\nreturn view('view', compact('value'));\n```\n\n\u003e **B)**\n\n```php\nreturn view('view', ['value' =\u003e 'Hello, World!']);\n```\n\n\u003e **C)**\n\n```php\nreturn view('view')\n    -\u003ewith('value', 'Hello, World!');\n```\n\nIn this case TLint will warn if you are not using the **B)** method.\nThis example is a sort of \"meta layer\" of code linting, allowing teams to avoid higher level sticking points of code review / discussions.\n\n## Usage\n\nFor entire project (you must pass the lint command to use other options)\n\n```\ntlint\n```\n\nFor individual files and specific directories\n\n```\ntlint lint index.php\ntlint lint app\n```\n\nYou can also lint only diff files by running the following with unstaged git changes\n\n```\ntlint lint --diff\ntlint lint src --diff\n```\n\nWant the output from a file as JSON? (Primarily used for integration with editor plugins)\n\n```\ntlint lint test.php --json\n```\n\nWant the output from a file as a [checkstyle XML report](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.22.0/doc/schemas/fix/checkstyle.xsd)? (Primarily used with CI tools like [reviewdog](https://github.com/reviewdog/reviewdog) and [cs2pr](https://github.com/staabm/annotate-pull-request-from-checkstyle))\n\n```\ntlint lint test.php --checkstyle\n```\n\nWant to only run a single linter?\n\n```\ntlint lint --only=ArrayParametersOverViewWith\n```\n\n## Example Output\n\n```bash\nLinting TestLaravelApp/routes/web.php\n============\nLints:\n============\n! Prefer `view(...)-\u003ewith(...)` over `view(..., [...])`.\n5 : `    return view('test', ['test' =\u003e 'test']);``\n```\n\n## Formatting\n\nUsing the same conventions as above, but using the format command, you can auto-fix some lints:\n\n```\ntlint format\n```\n\n## Linting Configuration\n\nTLint Ships with 2 \"preset\" styles: Laravel \u0026 Tighten.\nThe Laravel preset is intended to match the conventions agreed upon by the Laravel framework contributors, while the Tighten preset is intended to match those agreed upon by Tighten team members.\n\nThe default configuration is \"tighten\" flavored, but you may change this by adding a `tlint.json` file to your project's root directory with the following schema:\n\n\u003e You may further customize the linters used by adding specific lint names to the `\"disabled\"` list.\n\u003e You may disable linting for specific directories by adding them to the `\"excluded\"` list.\n\u003e You may provide custom paths by adding them to the `\"paths\"` lists.\n\n```json\n{\n    \"preset\": \"laravel\",\n    \"disabled\": [\"ArrayParametersOverViewWith\"],\n    \"excluded\": [\"tests/\"],\n    \"paths\": [\n        {\n            \"controllers\": [\"app/Domain/Http/Controllers\"]\n        }\n    ]\n}\n```\n\n### Custom Configuration \u0026 Presets\n\nYou can also add your own custom preset and linters by providing a fully-qualified class name as the preset. For example, if you created a custom preset class:\n\n```php\nnamespace App\\Support\\Linting;\n\nuse Tighten\\TLint\\Presets\\PresetInterface;\n\nclass Preset implements PresetInterface\n{\n  public function getLinters() : array\n  {\n    return [\n      CustomLinter::class,\n    ];\n  }\n\n  public function getFormatters() : array\n  {\n    return [\n        CustomFormatter::class,\n    ];\n  }\n}\n```\n\nThen your config could look like:\n\n```json\n{\n    \"preset\": \"App\\\\Support\\\\Linting\\\\Preset\"\n}\n```\n\nThis lets you define custom linting/formatting functionality, or modify the existing linters/formatters to your liking.\n\n## Editor Integrations\n\n### [PHPStorm](https://plugins.jetbrains.com/plugin/10703-tlint)\n\n\u003cimg src=\"tlint-phpstorm.png\" width=\"400px\" /\u003e\n\n### [Sublime](https://packagecontrol.io/packages/SublimeLinter-contrib-tlint)\n\n\u003cimg src=\"tlint-sublime.png\" width=\"400px\" /\u003e\n\n### [VSCode](https://marketplace.visualstudio.com/items?itemName=d9705996.tighten-lint)\n\n\u003cimg src=\"tlint-vscode.png\" width=\"400px\" /\u003e\n\n## Available Linters\n\n| Linter                                 | Description                                                                                                                                                                                                                                    |\n| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `ApplyMiddlewareInRoutes`              | Apply middleware in routes (not controllers).                                                                                                                                                                                                  |\n| `ArrayParametersOverViewWith`          | Prefer `view(..., [...])` over `view(...)-\u003ewith(...)`.                                                                                                                                                                                         |\n| `FullyQualifiedFacades`                | Import facades using their full namespace.                                                                                                                                                                                                     |\n| `MailableMethodsInBuild`               | Mailable values (from and subject etc) should be set in build().                                                                                                                                                                               |\n| `NoDatesPropertyOnModels`              | The `$dates` property was deprecated in Laravel 8. Use `$casts` instead.                                                                                                                                                                       |\n| `NoDocBlocksForMigrationUpDown`        | Remove doc blocks from the up and down method in migrations.                                                                                                                                                                                   |\n| `NoDumpDirectives`                     | Do not use the `@dump` or `@dd` directives.|\n| `NoJsonDirective`                      | Use blade `{{ $model }}` auto escaping for models, and double quotes via json_encode over @json blade directive: `\u003cvue-comp :values='@json($var)'\u003e` -\u003e `\u003cvue-comp :values=\"{{ $model }}\"\u003e` OR `\u003cvue-comp :values=\"{!! json_encode($var) !!}\"\u003e` |\n| `NoRayDirective`                       | Do not use the `@ray` directive.|\n| `NoLeadingSlashesOnRoutePaths`         | No leading slashes on route paths.                                                                                                                                                                                                             |\n| `NoRequestAll`                         | No `request()-\u003eall()`. Use `request()-\u003eonly(...)` to retrieve specific input values.                                                                                                                                                           |\n| `NoSpaceAfterBladeDirectives`          | No space between blade template directive names and the opening paren:`@section (` -\u003e `@section(`                                                                                                                                              |\n| `OneLineBetweenClassVisibilityChanges` | Class members of differing visibility must be separated by a blank line                                                                                                                                                                        |\n| `PureRestControllers`                  | You should not mix restful and non-restful public methods in a controller                                                                                                                                                                      |\n| `QualifiedNamesOnlyForClassName`       | Fully Qualified Class Names should only be used for accessing class names                                                                                                                                                                      |\n| `RemoveLeadingSlashNamespaces`         | Prefer `Namespace\\...` over `\\Namespace\\...`.                                                                                                                                                                                                  |\n| `RequestHelperFunctionWherePossible`   | Use the request(...) helper function directly to access request values wherever possible                                                                                                                                                       |\n| `RequestValidation`                    | Use `request()-\u003evalidate(...)` helper function or extract a FormRequest instead of using `$this-\u003evalidate(...)` in controllers                                                                                                                 |\n| `SpaceAfterBladeDirectives`            | Put a space between blade control structure names and the opening paren:`@if(` -\u003e `@if (`                                                                                                                                                      |\n| `SpacesAroundBladeRenderContent`       | Spaces around blade rendered content:`{{1 + 1}}` -\u003e `{{ 1 + 1 }}`                                                                                                                                                                              |\n| `UseAnonymousMigrations`               | Prefer anonymous class migrations.                                                                                                                                                                                                             |\n\n### General PHP\n\n-   `OneLineBetweenClassVisibilityChanges`\n-   `QualifiedNamesOnlyForClassName`\n-   `RemoveLeadingSlashNamespaces`\n\n### Laravel\n\n-   `ApplyMiddlewareInRoutes`\n-   `ArrayParametersOverViewWith`\n-   `FullyQualifiedFacades`\n-   `MailableMethodsInBuild`\n-   `NoLeadingSlashesOnRoutePaths`\n-   `NoDocBlocksForMigrationUpDown`\n-   `NoDumpDirectives`\n-   `NoJsonDirective`\n-   `NoRayDirective`\n-   `NoSpaceAfterBladeDirectives`, `SpaceAfterBladeDirectives`\n-   `PureRestControllers`\n-   `RequestHelperFunctionWherePossible`\n-   `RequestValidation`\n-   `SpacesAroundBladeRenderContent`\n-   `UseAnonymousMigrations`\n\n## Available Formatters\n\n**Notes about formatting**\n\n-   Formatting is designed to alter the least amount of code possible.\n-   Import related formatters are not designed to alter grouped imports.\n\n| Formatter                              | Description                                                                                                                    |\n| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| `ArrayParametersOverViewWith`          | Prefer `view(..., [...])` over `view(...)-\u003ewith(...)`.                                                                         |\n| `FullyQualifiedFacades`                | Import facades using their full namespace.                                                                                     |\n| `MailableMethodsInBuild`               | Mailable values (from and subject etc) should be set in build().                                                               |\n| `NoDatesPropertyOnModels`              | Use `$casts` instead of `$dates` on Eloquent models.                                                                           |\n| `NoDocBlocksForMigrationUpDown`        | Removes doc blocks from the up and down method in migrations.                                                                  |\n| `NoLeadingSlashesOnRoutePaths`         | No leading slashes on route paths.                                                                                             |\n| `NoSpaceAfterBladeDirectives`          | No space between blade template directive names and the opening paren:`@section (` -\u003e `@section(`                              |\n| `OneLineBetweenClassVisibilityChanges` | Class members of differing visibility must be separated by a blank line                                                        |\n| `RemoveLeadingSlashNamespaces`         | Prefer `Namespace\\...` over `\\Namespace\\...`.                                                                                  |\n| `RequestHelperFunctionWherePossible`   | Use the request(...) helper function directly to access request values wherever possible                                       |\n| `RequestValidation`                    | Use `request()-\u003evalidate(...)` helper function or extract a FormRequest instead of using `$this-\u003evalidate(...)` in controllers |\n| `SpaceAfterBladeDirectives`            | Put a space between blade control structure names and the opening paren:`@if(` -\u003e `@if (`                                      |\n| `SpacesAroundBladeRenderContent`       | Spaces around blade rendered content:`{{1 + 1}}` -\u003e `{{ 1 + 1 }}`                                                              |\n| `UseAnonymousMigrations`               | Prefer anonymous class migrations.                                                                                             |\n\n### General PHP\n\n-   `OneLineBetweenClassVisibilityChanges`\n-   `RemoveLeadingSlashNamespaces`\n\n### Laravel\n\n-   `ArrayParametersOverViewWith`\n-   `FullyQualifiedFacades`\n-   `MailableMethodsInBuild`\n-   `NoDatesPropertyOnModels`\n-   `NoDocBlocksForMigrationUpDown`\n-   `NoLeadingSlashesOnRoutePaths`\n-   `NoSpaceAfterBladeDirectives`\n-   `RequestHelperFunctionWherePossible`\n-   `RequestValidation`\n-   `SpaceAfterBladeDirectives`\n-   `SpacesAroundBladeRenderContent`\n-   `UseAnonymousMigrations`\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email hello@tighten.co instead of using the issue tracker.\n\n## Credits\n\n-   [Logan Henson](https://github.com/loganhenson)\n-   [Jacob Baker-Kretzmar](https://github.com/bakerkretzmar)\n-   [Anthony Clark](https://github.com/driftingly)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftighten%2Ftlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftighten%2Ftlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftighten%2Ftlint/lists"}