From baeb00506fd1e879441e1138ca7621e7fab42c9d Mon Sep 17 00:00:00 2001 From: Jonas Siewertsen Date: Sun, 10 Sep 2023 15:07:45 +0200 Subject: [PATCH 1/3] Add lint workflow --- .github/workflows/lint.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..bd47c41 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +on: + push: + +jobs: + lint: + name: ":Lint" + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: "Laravel Pint" + uses: aglipanci/laravel-pint-action@2.0.0 + with: + preset: laravel + pintVersion: 1.13.1 + + - name: Commit changes to GitHub + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Laravel Pint Linting" From 6eb2429f6cbd09055c370f66643a7143b8222783 Mon Sep 17 00:00:00 2001 From: jonassiewertsen Date: Sun, 10 Sep 2023 13:08:06 +0000 Subject: [PATCH 2/3] Laravel Pint Linting --- config/config.php | 10 +++++----- src/ServiceProvider.php | 4 ++-- src/Synthesizers/EntryCollectionSynthesizer.php | 10 +++++----- src/Synthesizers/EntrySynthesizer.php | 10 +++++----- src/Tags/Livewire.php | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/config/config.php b/config/config.php index 7d2cba7..f6f3f65 100644 --- a/config/config.php +++ b/config/config.php @@ -9,10 +9,10 @@ | | So called synthesizers allow to add custom types to Livewire, which can | can be used to make Livewire aware of Statamic classes that you want - | to work with, as it might make things easier. + | to work with, as it might make things easier. | | It's recommended to remove or uncomment those synthesizers that are - | not used in your application, to avoid overhead by loading those. + | not used in your application, to avoid overhead by loading those. | | This features is experimental. It's ment to be tested and to played | with. As long as it is experimental, it can be changed and removed @@ -27,6 +27,6 @@ 'classes' => [ \Jonassiewertsen\Livewire\Synthesizers\EntryCollectionSynthesizer::class, \Jonassiewertsen\Livewire\Synthesizers\EntrySynthesizer::class, - ] - ] -]; \ No newline at end of file + ], + ], +]; diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index c8dcaf6..aa4371d 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -17,11 +17,11 @@ public function boot(): void { parent::boot(); - $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'statamic-livewire'); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'statamic-livewire'); if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__ . '/../config/config.php' => config_path('statamic-livewire.php'), + __DIR__.'/../config/config.php' => config_path('statamic-livewire.php'), ], 'statamic-livewire'); } diff --git a/src/Synthesizers/EntryCollectionSynthesizer.php b/src/Synthesizers/EntryCollectionSynthesizer.php index 7696c3d..c1d1d89 100644 --- a/src/Synthesizers/EntryCollectionSynthesizer.php +++ b/src/Synthesizers/EntryCollectionSynthesizer.php @@ -9,12 +9,12 @@ class EntryCollectionSynthesizer extends Synth { public static $key = 'entry-collection'; - + public static function match($target) { return $target instanceof StatamicEntryCollection; } - + public function dehydrate($target) { $data = []; @@ -29,9 +29,9 @@ public function dehydrate($target) ]; } - return [ $data, [] ]; + return [$data, []]; } - + public function hydrate($values) { $items = []; @@ -49,6 +49,6 @@ public function hydrate($values) $items[] = $entry; } - return New StatamicEntryCollection($items); + return new StatamicEntryCollection($items); } } diff --git a/src/Synthesizers/EntrySynthesizer.php b/src/Synthesizers/EntrySynthesizer.php index ea3e861..e6649df 100644 --- a/src/Synthesizers/EntrySynthesizer.php +++ b/src/Synthesizers/EntrySynthesizer.php @@ -9,24 +9,24 @@ class EntrySynthesizer extends Synth { public static $key = 'entry-collection'; - + public static function match($target) { return $target instanceof StatamicEntry; } - + public function dehydrate($entry) { - return [ + return [ [ 'collection' => $entry->collection()->handle() ?? null, 'data' => $entry->data()->all(), 'date' => $entry->collection()->dated() ? $entry->date() : null, 'id' => $entry->id(), 'slug' => $entry->slug() ?? null, - ], [] ]; + ], []]; } - + public function hydrate($value) { $entry = Entry::make() diff --git a/src/Tags/Livewire.php b/src/Tags/Livewire.php index a47580c..f87344f 100644 --- a/src/Tags/Livewire.php +++ b/src/Tags/Livewire.php @@ -46,7 +46,7 @@ public function this(): string { $instanceId = $this->context['__livewire']->getId(); - if (!count($this->params)) { + if (! count($this->params)) { return "window.Livewire.find('{$instanceId}')"; } From 98617b5e52a77efc1adec1eeed1d141c97cbd4da Mon Sep 17 00:00:00 2001 From: Jonas Siewertsen Date: Sun, 10 Sep 2023 15:09:04 +0200 Subject: [PATCH 3/3] Adjust workflow --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bd47c41..4067999 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ on: jobs: lint: - name: ":Lint" + name: "Lint" runs-on: ubuntu-latest steps: - name: Checkout code @@ -18,4 +18,4 @@ jobs: - name: Commit changes to GitHub uses: stefanzweifel/git-auto-commit-action@v4 with: - commit_message: "Laravel Pint Linting" + commit_message: "[auto commit] Linting"