Skip to content

Commit

Permalink
Uses laravel preset by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jun 24, 2022
1 parent ea9b2eb commit 012f927
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ In addition, if you would like Pint to simply inspect your code for style errors
<a name="configuring"></a>
## Configuring Pint

**By default, Pint does not require any configuration** and will fix code style issues in your code by following the rules defined in the [PSR-12 Style Guide](https://www.php-fig.org/psr/psr-12).
**By default, Pint does not require any configuration** and will fix code style issues in your code by following the opinioned coding style of Laravel.

However, if you wish to customize the presets, rules, or inspected folders, you may do so by creating a `pint.json` file in your project's root directory:

```json
{
"preset": "psr12"
"preset": "laravel"
}
```

Expand All @@ -70,23 +70,23 @@ pint --config vendor/my-company/coding-style/pint.json
<a name="presets"></a>
### Presets

Presets define a set of rules that can be used to fix code style issues in your code. By default, Pint uses the `psr12` preset, which fixes issues by following the rules defined in the [PSR-12 Style Guide](https://www.php-fig.org/psr/psr-12).
Presets define a set of rules that can be used to fix code style issues in your code. By default, Pint uses the `laravel` preset, which fixes issues by following the opinioned coding style of Laravel.

However, you can use a different preset by passing the `--preset` option:

```bash
pint --preset laravel
pint --preset psr12
```

If you wish, you may also set the preset in your project's `pint.json` file:

```json
{
"preset": "laravel"
"preset": "psr12"
}
```

The currently supported presets are: `psr12`, `laravel`, and `symfony`.
The currently supported presets are: `laravel`, `psr12`, and `symfony`.

<a name="rules"></a>
### Rules
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/ConfigurationJsonRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function rules()
*/
public function preset()
{
return $this->preset ?: ($this->get()['preset'] ?? 'psr12');
return $this->preset ?: ($this->get()['preset'] ?? 'laravel');
}

/**
Expand Down
1 change: 0 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"preset": "laravel",
"exclude": [
"tests/Fixtures"
]
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/PresetTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

it('uses the PSR 12 by default', function () {
it('uses the laravel preset by default', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/without-issues'),
]);

expect($statusCode)->toBe(0)
->and($output)
->toContain('── PSR 12');
->toContain('── Laravel');
});

it('may use the PSR 12 preset', function () {
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/ProgressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
it('display progress when fixing issues', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/with-fixable-issues'),
'--preset' => 'psr12',
]);

expect($statusCode)->toBe(1)
Expand All @@ -13,6 +14,7 @@
it('display progress when detecting non fixable issues', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/with-non-fixable-issues'),
'--preset' => 'psr12',
]);

expect($statusCode)->toBe(1)
Expand All @@ -23,6 +25,7 @@
it('display progress when no issues were found', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/without-issues'),
'--preset' => 'psr12',
]);

expect($statusCode)->toBe(0)
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/SummaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
it('may fail with style issues', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/with-fixable-issues'),
'--preset' => 'psr12',
]);

expect($statusCode)->toBe(1)
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/VerboseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
it('displays the code diff', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/with-fixable-issues'),
'--preset' => 'psr12',
]);

expect($statusCode)->toBe(1)
Expand Down

0 comments on commit 012f927

Please sign in to comment.