Skip to content

Commit a25e963

Browse files
authored
ci: add linting (only check, without auto commit) (#64)
1 parent 191c255 commit a25e963

File tree

7 files changed

+88
-41
lines changed

7 files changed

+88
-41
lines changed

.github/workflows/linting.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
name: Linting
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches-ignore:
7+
- 'dependabot/npm_and_yarn/*'
8+
jobs:
9+
pint:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest]
14+
php: [8.3]
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.3'
24+
tools: composer:v2
25+
26+
- name: Copy .env
27+
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
28+
29+
- name: Get composer cache directory
30+
id: composer-cache
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
32+
33+
- name: Cache Composer dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
39+
40+
- name: Install Dependencies
41+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
42+
43+
- name: Launch Pint inspection
44+
run: vendor/bin/pint --test
45+

app/Http/Controllers/ShowDocumentationController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class ShowDocumentationController extends Controller
2222
{
23-
public function __invoke(Request $request, string $version, string $page = null)
23+
public function __invoke(Request $request, string $version, ?string $page = null)
2424
{
2525
if (config('app.env') === 'local') {
2626
Cache::flush();
@@ -123,15 +123,15 @@ protected function getNavigation(string $version): array
123123
$basePath = resource_path('views');
124124
$path = "$basePath/docs/$version";
125125

126-
$mainNavigation = (new Finder())
126+
$mainNavigation = (new Finder)
127127
->files()
128128
->name('_index.md')
129129
->depth(1)
130130
->in($path);
131131

132132
$navigation = collect();
133133

134-
$mainPages = (new Finder())
134+
$mainPages = (new Finder)
135135
->files()
136136
->notName('_index.md')
137137
->name('*.md')
@@ -145,7 +145,7 @@ protected function getNavigation(string $version): array
145145
$path = Str::after($mainPage->getPath(), $basePath).'/'.$mainPage->getBasename('.md');
146146

147147
$navigation->push([
148-
'path' => $path,
148+
'path' => $path,
149149
'title' => $parsedSection->matter('title', ''),
150150
'order' => $parsedSection->matter('order', 0),
151151
]);
@@ -156,11 +156,11 @@ protected function getNavigation(string $version): array
156156
$parsedSection = YamlFrontMatter::parse($section->getContents());
157157
$navigationEntry = [
158158
'relative_path' => $section->getRelativePath(),
159-
'title' => $parsedSection->matter('title', ''),
160-
'order' => $parsedSection->matter('order', 0),
159+
'title' => $parsedSection->matter('title', ''),
160+
'order' => $parsedSection->matter('order', 0),
161161
];
162162

163-
$subSections = (new Finder())
163+
$subSections = (new Finder)
164164
->files()
165165
->notName('_index.md')
166166
->name('*.md')
@@ -183,7 +183,7 @@ protected function getNavigation(string $version): array
183183
}
184184

185185
$children->push([
186-
'path' => $path,
186+
'path' => $path,
187187
'title' => $title,
188188
'order' => $parsedSection->matter('order', 0),
189189
]);
@@ -245,7 +245,7 @@ protected function redirectToFirstNavigationPage(array $navigation, $page = null
245245
{
246246
$firstNavigationPath = collect($navigation)
247247
->filter(function ($nav) use ($page) {
248-
if (!is_null($page)) {
248+
if (! is_null($page)) {
249249
return Arr::get($nav, 'relative_path') === $page;
250250
}
251251

@@ -267,7 +267,7 @@ protected function redirectToFirstNavigationPage(array $navigation, $page = null
267267
->flatten(1)
268268
->first();
269269

270-
if (is_null($firstNavigationPath) && !is_null($page)) {
270+
if (is_null($firstNavigationPath) && ! is_null($page)) {
271271
return $this->redirectToFirstNavigationPage($navigation);
272272
}
273273

app/Support/CommonMark/CommonMark.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class CommonMark
1111
{
1212
public static function convertToHtml(string $markdown): string
1313
{
14-
$converter = new CommonMarkConverter();
15-
$converter->getEnvironment()->addRenderer(Heading::class, new HeadingRenderer());
16-
$converter->getEnvironment()->addExtension(new TableExtension());
17-
$converter->getEnvironment()->addExtension(new TorchlightWithCopyExtension());
14+
$converter = new CommonMarkConverter;
15+
$converter->getEnvironment()->addRenderer(Heading::class, new HeadingRenderer);
16+
$converter->getEnvironment()->addExtension(new TableExtension);
17+
$converter->getEnvironment()->addExtension(new TorchlightWithCopyExtension);
1818

1919
return $converter->convert($markdown);
2020
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
}
4040
},
4141
"scripts": {
42+
"lint": "./vendor/bin/pint",
4243
"post-autoload-dump": [
4344
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
4445
"@php artisan package:discover --ansi"

config/seotools.php

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @see https://github.com/artesaos/seotools
45
*/
@@ -8,25 +9,25 @@
89
/*
910
* The default configurations to be used by the meta generator.
1011
*/
11-
'defaults' => [
12-
'title' => 'NativePHP', // set false to total remove
13-
'titleBefore' => false, // Put defaults.title before page title, like 'It's Over 9000! - Dashboard'
14-
'description' => 'Turn your Laravel app into a desktop app', // set false to total remove
15-
'separator' => ' - ',
16-
'keywords' => [],
17-
'canonical' => false, // Set to null or 'full' to use Url::full(), set to 'current' to use Url::current(), set false to total remove
18-
'robots' => false, // Set to 'all', 'none' or any combination of index/noindex and follow/nofollow
12+
'defaults' => [
13+
'title' => 'NativePHP', // set false to total remove
14+
'titleBefore' => false, // Put defaults.title before page title, like 'It's Over 9000! - Dashboard'
15+
'description' => 'Turn your Laravel app into a desktop app', // set false to total remove
16+
'separator' => ' - ',
17+
'keywords' => [],
18+
'canonical' => false, // Set to null or 'full' to use Url::full(), set to 'current' to use Url::current(), set false to total remove
19+
'robots' => false, // Set to 'all', 'none' or any combination of index/noindex and follow/nofollow
1920
],
2021
/*
2122
* Webmaster tags are always added.
2223
*/
2324
'webmaster_tags' => [
24-
'google' => null,
25-
'bing' => null,
26-
'alexa' => null,
25+
'google' => null,
26+
'bing' => null,
27+
'alexa' => null,
2728
'pinterest' => null,
28-
'yandex' => null,
29-
'norton' => null,
29+
'yandex' => null,
30+
'norton' => null,
3031
],
3132

3233
'add_notranslate_class' => false,
@@ -36,12 +37,12 @@
3637
* The default configurations to be used by the opengraph generator.
3738
*/
3839
'defaults' => [
39-
'title' => 'Herd', // set false to total remove
40-
'description' => 'Launch Laravel faster than ever before.', // set false to total remove
41-
'url' => false, // Set null for using Url::current(), set false to total remove
42-
'type' => false,
43-
'site_name' => false,
44-
'images' => [],
40+
'title' => 'Herd', // set false to total remove
41+
'description' => 'Launch Laravel faster than ever before.', // set false to total remove
42+
'url' => false, // Set null for using Url::current(), set false to total remove
43+
'type' => false,
44+
'site_name' => false,
45+
'images' => [],
4546
],
4647
],
4748
'twitter' => [
@@ -58,11 +59,11 @@
5859
* The default configurations to be used by the json-ld generator.
5960
*/
6061
'defaults' => [
61-
'title' => 'Herd', // set false to total remove
62-
'description' => 'Launch Laravel faster than ever before.', // set false to total remove
63-
'url' => false, // Set to null or 'full' to use Url::full(), set to 'current' to use Url::current(), set false to total remove
64-
'type' => 'WebPage',
65-
'images' => [],
62+
'title' => 'Herd', // set false to total remove
63+
'description' => 'Launch Laravel faster than ever before.', // set false to total remove
64+
'url' => false, // Set to null or 'full' to use Url::full(), set to 'current' to use Url::current(), set false to total remove
65+
'type' => 'WebPage',
66+
'images' => [],
6667
],
6768
],
6869
];

config/torchlight.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
// block, Torchlight will look for code snippets in the
4141
// following directories.
4242
'snippet_directories' => [
43-
resource_path()
43+
resource_path(),
4444
],
4545

4646
// Global options to control blocks-level settings.
@@ -65,5 +65,5 @@
6565

6666
// Show or hide the copy button on code blocks.
6767
'copyable' => true,
68-
]
68+
],
6969
];

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
use Illuminate\Support\Facades\Route;
43
use App\Http\Controllers\ShowDocumentationController;
4+
use Illuminate\Support\Facades\Route;
55
use Illuminate\Support\Str;
66

77
/*

0 commit comments

Comments
 (0)