Unable to modify no_extra_blank_lines tokens via pint.json
lada opened this issue · comments
- Pint Version: 1.2.0
- PHP Version: 8.1.9
Description:
I was trying to overwrite the laravel preset so that extra blank lines after class methods don't get removed. But overwriting the no_extra_blank_lines
rule in pint.json does not have any effect (while overwriting other rules works as expected).
Steps To Reproduce:
Create pint.json file in project root with the following content:
{
"preset": "laravel",
"rules": {
"no_extra_blank_lines": {
"tokens": [
"throw",
"use"
]
}
}
}
Extra blank lines after class methods are still removed.
Here are more detailed steps to reproduce the issue:
- Create a new laravel project
composer create-project laravel/laravel pint-blank-lines-issue
- Create pint.json file in the project root with the following content:
{
"preset": "laravel",
"rules": {
"no_extra_blank_lines": {
"tokens": [
"throw",
"use"
]
}
}
}
- Open app/Providers/AppServiceProvider.php and insert one more blank line after the register method
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}
- Run pint
./vendor/bin/pint
The extra blank line will be removed. But it should not be, because the pint.json file specifies only "throws" and "use" tokens.
Sorry guys, I have just seen that the single blank line after class method is enforces by the class_attributes_separation
rule. Modifying the pint.json as follows solves the issue:
{
"preset": "laravel",
"rules": {
"class_attributes_separation": false,
"no_extra_blank_lines": {
"tokens": [
"throw",
"use"
]
}
}
}