diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 6467ca08..a2e6e21c 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -27,6 +27,11 @@ jobs: if: ${{ github.event_name != 'pull_request' }} uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '22' + - name: Install prettier and plugin-php run: npm i diff --git a/.prettierignore b/.prettierignore index b7c990df..b5449b69 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ vendor -**/*.min.js \ No newline at end of file +**/*.min.js +.prettierrc \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 2a1fc68e..00000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "printWidth": 120, - "endOfLine": "auto" -} \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..3a7657e1 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,13 @@ +module.exports = { + printWidth: 120, + endOfLine: "auto", + plugins: ["@prettier/plugin-php"], + overrides: [ + { + files: "*.php", + options: { + parser: "php", + }, + }, + ], +}; diff --git a/scripts/translation-progress.php b/scripts/translation-progress.php index 30289d27..7d9c58b7 100644 --- a/scripts/translation-progress.php +++ b/scripts/translation-progress.php @@ -123,6 +123,6 @@ function updateReadme(string $path, string $start, string $end, string $content) __DIR__ . "/../README.md", "", "", - $badges + $badges, ); exit($update === false ? 1 : 0); diff --git a/src/card.php b/src/card.php index b1532e83..501f80cc 100644 --- a/src/card.php +++ b/src/card.php @@ -27,7 +27,7 @@ function formatDate(string $dateString, string|null $format, string $locale): st $locale, IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, - pattern: $pattern + pattern: $pattern, ); $formatted = $dateFormatter->format($date); } @@ -44,7 +44,7 @@ function formatDate(string $dateString, string|null $format, string $locale): st $locale, IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, - pattern: $pattern + pattern: $pattern, ); $formatted = $dateFormatter->format($date); } @@ -75,7 +75,7 @@ function translateDays(array $days, string $locale): array $locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE, - pattern: $pattern + pattern: $pattern, ); $translatedDays = []; foreach ($days as $day) { @@ -250,7 +250,7 @@ function splitLines(string $text, int $maxChars, int $line1Offset): string return preg_replace( "/^(.*)\n(.*)/", "$1$2", - $text + $text, ); } @@ -752,7 +752,7 @@ function ($matches) { $opacity = $result["opacity"]; return "{$attribute}='{$color}' {$opacityAttribute}='{$opacity}'"; }, - $svg + $svg, ); return $svg; diff --git a/src/demo/css/style.css b/src/demo/css/style.css index f57b550d..852763a6 100644 --- a/src/demo/css/style.css +++ b/src/demo/css/style.css @@ -44,7 +44,10 @@ html { body { background: var(--background); - font-family: Segoe UI, Ubuntu, sans-serif; + font-family: + Segoe UI, + Ubuntu, + sans-serif; padding-top: 10px; color: var(--text); } @@ -105,7 +108,9 @@ h2 { border-radius: 6px; cursor: pointer; font-family: inherit; - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); + box-shadow: + 0 1px 3px rgba(0, 0, 0, 0.12), + 0 1px 2px rgba(0, 0, 0, 0.24); transition: 0.2s ease-in-out; } @@ -115,7 +120,9 @@ h2 { .btn:hover { background-color: var(--blue-dark); - box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); + box-shadow: + 0 3px 6px rgba(0, 0, 0, 0.16), + 0 3px 6px rgba(0, 0, 0, 0.23); } .btn:disabled { diff --git a/src/demo/css/toggle-dark.css b/src/demo/css/toggle-dark.css index 1fe526f3..227a54ed 100644 --- a/src/demo/css/toggle-dark.css +++ b/src/demo/css/toggle-dark.css @@ -11,12 +11,16 @@ a.darkmode { justify-content: center; border-radius: 50%; border: 2px solid var(--border); - box-shadow: 0 0 3px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 24%); + box-shadow: + 0 0 3px rgb(0 0 0 / 12%), + 0 1px 2px rgb(0 0 0 / 24%); transition: 0.2s ease-in box-shadow; } a.darkmode:hover { - box-shadow: 0 0 6px rgb(0 0 0 / 16%), 0 3px 6px rgb(0 0 0 / 23%); + box-shadow: + 0 0 6px rgb(0 0 0 / 16%), + 0 3px 6px rgb(0 0 0 / 23%); } @media only screen and (max-width: 600px) { diff --git a/src/demo/index.php b/src/demo/index.php index 62f02c4e..81e97011 100644 --- a/src/demo/index.php +++ b/src/demo/index.php @@ -22,7 +22,7 @@ function camelToSkewer(string $str): string function ($matches) { return "-" . strtolower($matches[0]); }, - $str + $str, ); } ?> diff --git a/src/demo/js/accordion.js b/src/demo/js/accordion.js index 78e4e997..48e4deab 100644 --- a/src/demo/js/accordion.js +++ b/src/demo/js/accordion.js @@ -55,7 +55,7 @@ class Accordion { { duration: 400, easing: "ease-out", - } + }, ); // When the animation is complete, call onAnimationFinish() this.animation.onfinish = () => this.onAnimationFinish(false); @@ -93,7 +93,7 @@ class Accordion { { duration: 400, easing: "ease-out", - } + }, ); // When the animation is complete, call onAnimationFinish() this.animation.onfinish = () => this.onAnimationFinish(true); diff --git a/src/demo/js/script.js b/src/demo/js/script.js index 8239318a..465614a5 100644 --- a/src/demo/js/script.js +++ b/src/demo/js/script.js @@ -143,7 +143,7 @@ const preview = { format: "hexa", onChange: `preview.pickerChange(this, '${color1.id}')`, onInput: `preview.pickerChange(this, '${color1.id}')`, - }) + }), ); const color2 = document.createElement("input"); color2.className = "param jscolor"; @@ -154,7 +154,7 @@ const preview = { format: "hexa", onChange: `preview.pickerChange(this, '${color2.id}')`, onInput: `preview.pickerChange(this, '${color2.id}')`, - }) + }), ); rotate.name = color1.name = color2.name = propertyName; color1.value = color1Value; @@ -484,5 +484,5 @@ window.addEventListener( // update previews preview.update(); }, - false + false, ); diff --git a/src/stats.php b/src/stats.php index 6511758c..74e29e55 100644 --- a/src/stats.php +++ b/src/stats.php @@ -210,7 +210,7 @@ function removeGitHubToken(string $token): void if (empty($GLOBALS["ALL_TOKENS"])) { throw new AssertionError( "We are being rate-limited! Check git.io/streak-ratelimit for details.", - 429 + 429, ); } } @@ -287,7 +287,7 @@ function normalizeDays(array $days): array $dayOfWeek = substr(ucfirst(strtolower(trim($dayOfWeek))), 0, 3); // return day if valid, otherwise return null return in_array($dayOfWeek, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]) ? $dayOfWeek : null; - }, $days) + }, $days), ); } diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php index 370ec171..127d6955 100644 --- a/tests/OptionsTest.php +++ b/tests/OptionsTest.php @@ -74,7 +74,7 @@ public function testThemesHaveValidParameters(): void $this->assertEquals( array_diff_key($colors, $this->defaultTheme), [], - "The theme '$theme' contains invalid parameters." + "The theme '$theme' contains invalid parameters.", ); # check that no parameters are missing and all values are valid foreach (array_keys($this->defaultTheme) as $param) { @@ -85,7 +85,7 @@ public function testThemesHaveValidParameters(): void $this->assertMatchesRegularExpression( $backgroundRegex, $colors[$param], - "The parameter '$param' of '$theme' is not a valid background value." + "The parameter '$param' of '$theme' is not a valid background value.", ); continue; } @@ -93,13 +93,13 @@ public function testThemesHaveValidParameters(): void $this->assertMatchesRegularExpression( $hexRegex, strtoupper($colors[$param]), - "The parameter '$param' of '$theme' is not a valid hex color." + "The parameter '$param' of '$theme' is not a valid hex color.", ); // check that the key is a valid hex color in uppercase $this->assertMatchesRegularExpression( $hexRegex, $colors[$param], - "The parameter '$param' of '$theme' should not contain lowercase letters." + "The parameter '$param' of '$theme' should not contain lowercase letters.", ); } } @@ -251,7 +251,7 @@ public function testAllThemeNamesNormalized(): void $this->assertEquals( $theme, $normalized, - "Theme name '$theme' is not normalized. It should contain only lowercase letters, numbers, and dashes. Consider renaming it to '$normalized'." + "Theme name '$theme' is not normalized. It should contain only lowercase letters, numbers, and dashes. Consider renaming it to '$normalized'.", ); } } diff --git a/tests/RenderTest.php b/tests/RenderTest.php index deb492b2..6fd8dcc9 100644 --- a/tests/RenderTest.php +++ b/tests/RenderTest.php @@ -112,7 +112,7 @@ public function testBorderRadius(): void $this->assertStringContainsString("", $render); $this->assertStringContainsString( "", - $render + $render, ); } @@ -126,19 +126,19 @@ public function testSplitLines(): void // Check label that is too long, split $this->assertEquals( "Chuỗi đóng góp hiệntại", - splitLines("Chuỗi đóng góp hiện tại", 22, -9) + splitLines("Chuỗi đóng góp hiện tại", 22, -9), ); // Check label with manually inserted line break, split $this->assertEquals( "Chuỗi đóng góphiện tại", - splitLines("Chuỗi đóng góp\nhiện tại", 22, -9) + splitLines("Chuỗi đóng góp\nhiện tại", 22, -9), ); // Check date range label, no split $this->assertEquals("Mar 28, 2019 – Apr 12, 2019", splitLines("Mar 28, 2019 – Apr 12, 2019", 28, 0)); // Check date range label that is too long, split $this->assertEquals( "19 de dez. de 2021- 14 de mar.", - splitLines("19 de dez. de 2021 - 14 de mar.", 24, 0) + splitLines("19 de dez. de 2021 - 14 de mar.", 24, 0), ); } @@ -194,7 +194,7 @@ public function testGradientBackground(): void $this->assertStringContainsString("fill='url(#gradient)'", $render); $this->assertStringContainsString( "", - $render + $render, ); } @@ -208,7 +208,7 @@ public function testGradientBackgroundWithMoreThan2Colors(): void $this->assertStringContainsString("fill='url(#gradient)'", $render); $this->assertStringContainsString( "", - $render + $render, ); } @@ -263,11 +263,11 @@ public function testFirstAndThirdColumnsSwappedWhenDirectionIsRtl(): void $render = generateOutput($this->testStats, $this->testParams)["body"]; $this->assertMatchesRegularExpression( "/\\s*/", - $render + $render, ); $this->assertMatchesRegularExpression( "/\\s*/", - $render + $render, ); }