Skip to content

Commit

Permalink
feat: 🎸 add option --wrap-attributes-min-attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo committed Aug 11, 2023
1 parent 6cde000 commit 9099b45
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
7 changes: 7 additions & 0 deletions __tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ describe('CLI test', () => {
toDir: path.resolve('__tests__', 'fixtures', 'runtimeConfig', 'singleQuote'),
to: 'formatted.index.blade.php',
},
{
name: '.prettierrc.json with wrap attributes min attrs option',
fromDir: path.resolve('__tests__', 'fixtures', 'runtimeConfig', 'wrapAttributesMinAttrs'),
from: 'index.blade.php',
toDir: path.resolve('__tests__', 'fixtures', 'runtimeConfig', 'wrapAttributesMinAttrs'),
to: 'formatted.index.blade.php',
},
];

targets.forEach(target => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"overrides": [
{
"files": ["*.blade.php"],
"options": {
"tabWidth": 4,
"parser": "blade"
}
}
],
"wrapAttributes": "force-expand-multiline",
"wrapAttributesMinAttrs": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@extends('frontend.layouts.app')
@section('head')
@endsection
@section('title') foo
@endsection
@section('content')
<section
id="content"
>
<div
class="container mod-users-pd-h"
>
<div
class="pf-user-header"
>
<div></div>
<p>@lang('users.index')</p>
</div>
<div
class="pf-users-branch"
>
<ul
class="pf-users-branch__list"
>
@foreach ($tree as $users)
<li>
<img
src="{{ asset('img/frontend/icon/branch-arrow.svg') }}"
alt="branch_arrow"
>
{{ link_to_route('frontend.users.user.show', $users['name'], $users['_id']) }}
</li>
@endforeach
</ul>
<div
class="pf-users-branch__btn"
>
@can('create', App\Models\User::class)
{!! link_to_route('frontend.users.user.create', __('users.create'), [], ['class' => 'btn']) !!}
@endcan
</div>
</div>
</div>
</section>
@endsection
@section('footer')
@stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@extends('frontend.layouts.app')
@section('head')
@endsection
@section('title') foo
@endsection
@section('content')
<section id="content">
<div class="container mod-users-pd-h">
<div class="pf-user-header">
<div></div>
<p>@lang('users.index')</p>
</div>
<div class="pf-users-branch">
<ul class="pf-users-branch__list">
@foreach($tree as $users)
<li>
<img src="{{ asset("img/frontend/icon/branch-arrow.svg") }}" alt="branch_arrow">
{{ link_to_route('frontend.users.user.show',$users["name"],$users['_id']) }}
</li>
@endforeach
</ul>
<div class="pf-users-branch__btn">
@can('create', App\Models\User::class)
{!! link_to_route('frontend.users.user.create', __('users.create'), [], ['class' => 'btn']) !!}
@endcan
</div>
</div>
</div>
</section>
@endsection
@section('footer')
@stop
8 changes: 8 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export const options = {
"The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]",
since: "1.0.0",
},
wrapAttributesMinAttrs: {
type: "int",
category: "Blade",
default: 2,
description:
"Minimum number of html tag attributes for force wrap attribute options. Wrap the first attribute only if 'force-expand-multiline' is specified in wrap attributes",
since: "1.11.0",
},
endWithNewLine: {
type: "boolean",
category: "Blade",
Expand Down
1 change: 1 addition & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const parse = async (
: opts.bracketSameLine
? "force-aligned"
: opts.wrapAttributes,
wrapAttributesMinAttrs: opts.wrapAttributesMinAttrs,
endWithNewline: opts.endWithNewline,
useTabs: opts.useTabs,
sortTailwindcssClasses: opts.sortTailwindcssClasses,
Expand Down

0 comments on commit 9099b45

Please sign in to comment.