Unused imports aren't deleted
Jens-dev opened this issue · comments
- Pint Version: 1.6
- PHP Version: 8.2.1
- Laravel Version: 10
Pint Config
{
"preset": "laravel",
"rules": {
"no_unused_imports": true,
"ordered_imports": true,
"phpdoc_align": true,
"phpdoc_order": true,
"single_line_comment_style": true,
"single_quote": true,
"yoda_style": true
}
}
Description:
Pint does not delete unused imports.
Neither with the laravel preset nor if you set it explicitly via no_unused_imports
.
I'm not sure if I missconfigured something or Pint is simply not Laravel 10 ready, but I can't explain the behavior.
THX for your Support.
Steps To Reproduce:
Code before
<?php
namespace App\Http\Controllers\Api\VetAppointment;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class GetAction extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(): JsonResponse
{
return response()->json([
'message' => 'Hello World',
]);
}
}
running pint
Code after
<?php
namespace App\Http\Controllers\Api\VetAppointment;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class GetAction extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(): JsonResponse
{
return response()->json([
'message' => 'Hello World',
]);
}
}
and use Illuminate\Http\Request;
is still there.
I can't reproduce this. no_unused_imports
is already part of the Laravel preset and it makes no difference when I add it or not to my pint.json config: the unused imports always get cleaned up.
Please try a support channel:
I've also started seeing this issue – it only stopped working after recently upgrading Laravel (when I also bumped the version on a load of other composer packages, so not specifically the Laravel upgrade which caused this).
- Pint Version: 1.6.0
- PHP Version: 8.2.3
- Laravel Version: 10.3.3
Thought it was a weird issue due to running on save from PhpStorm, but I'm getting exactly the same behaviour when running from command line as well.