Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.x Release #340

Merged
merged 16 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/run-duster.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: Run Duster

on:
push:
branches: [ main ]
pull_request:
push:
branches: main
pull_request:

jobs:
duster:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: "Duster"
uses: tighten/duster-action@v1
uses: tighten/duster-action@v2
with:
args: lint
11 changes: 2 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ on:
- cron: "0 0 * * *"
jobs:
test:
name: PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony[0] }}, ${{ matrix.dependencies }}, ${{ matrix.os }}
name: PHP ${{ matrix.php }}, ${{ matrix.dependencies }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, macos, windows]
php: ["8.0", "8.1", "8.2"]
symfony:
[
[4, "^4.4.30", "^4.4.20"],
[5, "^5.3.7", "^5.0.9"],
[6, "^6.0", "^6.0"],
]
php: ["8.1", "8.2"]
dependencies: [lowest, stable]
steps:
- uses: actions/checkout@v2
Expand All @@ -33,7 +27,6 @@ jobs:
with:
php-version: ${{ matrix.php }}
- run: |
composer require symfony/console:${{ matrix.symfony[1] }} symfony/process:${{ matrix.symfony[2] }} --no-update --no-interaction
composer update --prefer-${{ matrix.dependencies }} --prefer-dist --no-interaction
composer require illuminate/view:* --with-all-dependencies --no-interaction
- run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion bin/tlint
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php

const TLINT_VERSION = 'v8.0.3';
const TLINT_VERSION = 'v9.0.0';

foreach (
[
Expand Down
20 changes: 9 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"illuminate/view": "*",
"nikic/php-parser": "^4.15",
"symfony/console": "^4.4.30 || ^5.3.7 || ^6.0",
"symfony/process": "^4.4.20 || ^5.0.9 || ^6.0"
"symfony/console": "^6.1",
"symfony/process": "^6.1"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"spatie/ray": "^1.36",
"symfony/var-dumper": "^5.0",
"tightenco/duster": "^1.0"
"phpunit/phpunit": "^9.6",
"spatie/ray": "^1.37",
"symfony/var-dumper": "^6.1",
"tightenco/duster": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -38,19 +38,17 @@
"bin/tlint"
],
"scripts": {
"bumpVersion": "sed -i '' \"/TLINT_VERSION/ s/'v.*'/'$(git describe --abbrev=0 --tag)'/\" ./bin/tlint",
"generate-readme-tables": "php ./scripts/generateLintersFormattersTables.php",
"update-fixture-app": [
"rm -rf ./tests/fixtures/laravel",
"composer create-project laravel/laravel ./tests/fixtures/laravel",
"echo '{\"preset\":\"laravel\"}' > ./tests/fixtures/laravel/tlint.json",
"rm -rf ./tests/fixtures/laravel/composer.lock"
],
"lint": [
"vendor/bin/duster"
"vendor/bin/duster lint"
],
"fix": [
"vendor/bin/duster --fix"
"vendor/bin/duster fix"
]
},
"config": {
Expand Down
55 changes: 33 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,47 @@

[![Latest Version on Packagist](https://img.shields.io/packagist/v/tightenco/tlint.svg?style=flat-square)](https://packagist.org/packages/tightenco/tlint)

## Install (Requires PHP 8.0+)
## Install (Requires PHP 8.1+)

>**Note**
>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.

```
```bash
# Include in project
composer require tightenco/tlint --dev

# Include globally
composer global require tightenco/tlint
```

## Upgrade

```
```bash
# Upgrade in project
composer update tightenco/tlint

#Upgrade globally
composer global update tightenco/tlint
```

### Upgrading from 8.x to 9.x

TLint 9 requires PHP >= 8.1.

`tformat.json` has been dropped in favor of a single `tlint.json` file.

Now linting the following files and directories:

- `public/`
- `bootstrap/`
- `server.php`
- `app/Http/Middleware/RedirectIfAuthenticated.php`
- `Exceptions/Handler.php`
- `app/Http/Controllers/Auth/`
- `app/Http/Kernel.php`

To continue excluding these files and directories add them to your `tlint.json` file under `excluded`.

### Upgrading from 7.x to 8.x

A significant number of formatters were added between the 7.x and 8.x releases.
Expand Down Expand Up @@ -104,7 +130,7 @@ Lints:
5 : ` return view('test', ['test' => 'test']);``
```

## Formatting (Beta)
## Formatting

Using the same conventions as above, but using the format command, you can auto-fix some lints:

Expand Down Expand Up @@ -171,19 +197,7 @@ Then your config could look like:
}
```

This lets you define whatever custom linting functionality, or modify the existing linters to your liking.

## Formatting Configuration (Beta)

Similar to linting there are two "preset" styles for formatting: Laravel & Tighten.

The default configuration is "tighten", but you may change this by adding a `tformat.json` file to your project's root directory with the following schema:

```json
{
"preset": "laravel"
}
```
This lets you define custom linting/formatting functionality, or modify the existing linters/formatters to your liking.

## Editor Integrations

Expand All @@ -201,7 +215,6 @@ The default configuration is "tighten", but you may change this by adding a `tfo

## Available Linters

<!-- linters -->
| Linter | Description |
| --- | --- |
| `ApplyMiddlewareInRoutes` | Apply middleware in routes (not controllers). |
Expand All @@ -224,7 +237,6 @@ The default configuration is "tighten", but you may change this by adding a `tfo
| `SpacesAroundBladeRenderContent` | Spaces around blade rendered content:`{{1 + 1}}` -> `{{ 1 + 1 }}` |
| `UseAnonymousMigrations` | Prefer anonymous class migrations. |
| `UseAuthHelperOverFacade` | Prefer the `auth()` helper function over the `Auth` Facade. |
<!-- /linters -->

### General PHP

Expand All @@ -249,14 +261,13 @@ The default configuration is "tighten", but you may change this by adding a `tfo
- `UseAnonymousMigrations`
- `UseAuthHelperOverFacade`

## Available Formatters (Beta)
## Available Formatters

**Notes about formatting**

- Formatting is designed to alter the least amount of code possible.
- Import related formatters are not designed to alter grouped imports.

<!-- formatters -->
| Formatter | Description |
| --- | --- |
| `ArrayParametersOverViewWith` | Prefer `view(..., [...])` over `view(...)->with(...)`. |
Expand All @@ -274,7 +285,6 @@ The default configuration is "tighten", but you may change this by adding a `tfo
| `SpacesAroundBladeRenderContent` | Spaces around blade rendered content:`{{1 + 1}}` -> `{{ 1 + 1 }}` |
| `UseAnonymousMigrations` | Prefer anonymous class migrations. |
| `UseAuthHelperOverFacade` | Prefer the `auth()` helper function over the `Auth` Facade. |
<!-- /formatters -->

### General PHP

Expand Down Expand Up @@ -309,6 +319,7 @@ If you discover any security related issues, please email hello@tighten.co inste

- [Logan Henson](https://github.com/loganhenson)
- [Jacob Baker-Kretzmar](https://github.com/bakerkretzmar)
- [Anthony Clark](https://github.com/driftingly)
- [All Contributors](../../contributors)

## License
Expand Down
34 changes: 0 additions & 34 deletions scripts/generateLintersFormattersTables.php

This file was deleted.

7 changes: 0 additions & 7 deletions src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ protected function isBlacklisted($filepath)

return strpos($filepath, 'vendor') !== false
|| strpos($filepath, 'node_modules') !== false
|| strpos($filepath, "public{$DS}") !== false
|| strpos($filepath, "bootstrap{$DS}") !== false
|| strpos($filepath, 'server.php') !== false
|| strpos($filepath, "app{$DS}Http{$DS}Middleware{$DS}RedirectIfAuthenticated.php") !== false
|| strpos($filepath, "app{$DS}Exceptions{$DS}Handler.php") !== false
|| strpos($filepath, "app{$DS}Http{$DS}Controllers{$DS}Auth") !== false
|| strpos($filepath, "app{$DS}Http{$DS}Kernel.php") !== false
|| strpos($filepath, "storage{$DS}framework{$DS}views") !== false
|| $this->isExcluded($filepath);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/FormatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private function formatFile(InputInterface $input, OutputInterface $output, $fil

private function getFormatters($path)
{
$configPath = getcwd() . '/tformat.json';
$configPath = getcwd() . '/tlint.json';
$config = new Config(json_decode(is_file($configPath) ? file_get_contents($configPath) : '', true) ?? null);

return array_filter($config->getFormatters(), function ($className) use ($path) {
Expand Down
3 changes: 0 additions & 3 deletions src/Presets/LaravelPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ public function getLinters(): array
Linters\NoLeadingSlashesOnRoutePaths::class,
Linters\NoSpaceAfterBladeDirectives::class,
Linters\OneLineBetweenClassVisibilityChanges::class,
Linters\QualifiedNamesOnlyForClassName::class,
Linters\RemoveLeadingSlashNamespaces::class,
Linters\RequestHelperFunctionWherePossible::class,
Linters\RequestValidation::class,
Linters\SpaceAfterBladeDirectives::class,
Linters\SpacesAroundBladeRenderContent::class,
Linters\UseAuthHelperOverFacade::class,
];
}

Expand All @@ -43,7 +41,6 @@ public function getFormatters(): array
Formatters\RequestValidation::class,
Formatters\SpaceAfterBladeDirectives::class,
Formatters\SpacesAroundBladeRenderContent::class,
Formatters\UseAuthHelperOverFacade::class,
];
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/laravel/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/laravel/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/laravel/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/laravel/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
Expand All @@ -6,11 +7,13 @@
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
2 changes: 1 addition & 1 deletion tests/fixtures/laravel/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>

<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
Expand Down
9 changes: 2 additions & 7 deletions tests/fixtures/laravel/app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

Expand Down
Loading