From c0b8020b4ca2f7853687dafbb2b76ee4c6f2f70a Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 7 Mar 2025 01:01:29 +0100 Subject: [PATCH 1/7] Update prettier support to be more portable --- .github/workflows/prettier.yml | 2 +- .prettierignore | 1 + .prettierrc | 3 +++ composer.json | 4 ++-- package.json | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .prettierrc diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index a04126ee..6467ca08 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v3 - name: Install prettier and plugin-php - run: npm install --global prettier@2.8.1 @prettier/plugin-php@0.18.9 + run: npm i - name: Lint with Prettier continue-on-error: true diff --git a/.prettierignore b/.prettierignore index 22d0d82f..cb2a77e8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ vendor +!**/*.min.js \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..94d737c3 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "printWidth": 120 +} \ No newline at end of file diff --git a/composer.json b/composer.json index 82a95b97..31d5a963 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "php -S localhost:8000 -t src" ], "test": "./vendor/bin/phpunit --testdox tests", - "lint": "prettier --check *.md **/*.{php,md,js,css} !**/*.min.js --print-width 120", - "lint-fix": "prettier --write *.md **/*.{php,md,js,css} !**/*.min.js --print-width 120" + "lint": "./node_modules/.bin/prettier --check *.md **/*.{php,md,js,css}", + "lint-fix": "./node_modules/.bin/prettier --write *.md **/*.{php,md,js,css}" } } diff --git a/package.json b/package.json index fb08e235..87efaaa9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "node": "18.x" }, "devDependencies": { - "@prettier/plugin-php": "^0.18.8", - "prettier": "^2.6.2" + "@prettier/plugin-php": "^0.18.9", + "prettier": "^2.8.1" } } From 88f8d688c8db459220839d06a73c9926c301bc51 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 7 Mar 2025 01:05:27 +0100 Subject: [PATCH 2/7] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 24ee490f..ea2ef0ba 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,10 @@ package-lock.json # Environment .env +.php-version DOCKER_ENV docker_tag # IDE .vscode/ -.idea/ \ No newline at end of file +.idea/ From 2d6e418a891701bc8b8ec3a5be0bce80390c56ab Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 7 Mar 2025 01:21:38 +0100 Subject: [PATCH 3/7] Enforce lf when possible and use auto otherwise --- .editorconfig | 12 ++++++++++++ .gitattributes | 2 +- .prettierrc | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..60a2751d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index dfe07704..5a0d5e48 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ # Auto detect text files and perform LF normalization -* text=auto +* text=auto eol=lf diff --git a/.prettierrc b/.prettierrc index 94d737c3..2a1fc68e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,4 @@ { - "printWidth": 120 + "printWidth": 120, + "endOfLine": "auto" } \ No newline at end of file From 7f68c4af7e372351bed8867758bc481c600fa1b1 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 7 Mar 2025 01:21:50 +0100 Subject: [PATCH 4/7] Use npx to run node commands --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 31d5a963..63e189c3 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "php -S localhost:8000 -t src" ], "test": "./vendor/bin/phpunit --testdox tests", - "lint": "./node_modules/.bin/prettier --check *.md **/*.{php,md,js,css}", - "lint-fix": "./node_modules/.bin/prettier --write *.md **/*.{php,md,js,css}" + "lint": "npx prettier --check *.md **/*.{php,md,js,css}", + "lint-fix": "npx prettier --write *.md **/*.{php,md,js,css}" } } From 2114e831d6ffd2a3d4731f55eb64355a5d4ea0d1 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 7 Mar 2025 01:23:02 +0100 Subject: [PATCH 5/7] Set indent_size to 2 for md files --- .editorconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 60a2751d..88b723dc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,4 +9,5 @@ trim_trailing_whitespace = true insert_final_newline = true [*.md] -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false +indent_size = 2 \ No newline at end of file From cd16b79962c8c81c135e4a1ccbd48325ea907423 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 7 Mar 2025 01:25:53 +0100 Subject: [PATCH 6/7] Fix js and css linting configuration --- .editorconfig | 5 ++++- .prettierignore | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 88b723dc..f14aa549 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,4 +10,7 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false -indent_size = 2 \ No newline at end of file +indent_size = 2 + +[*.{js,css}] +indent_size = 2 diff --git a/.prettierignore b/.prettierignore index cb2a77e8..b7c990df 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,2 @@ vendor -!**/*.min.js \ No newline at end of file +**/*.min.js \ No newline at end of file From 0da81a32665ccc2b936a18120021053f3f3ea56a Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 28 Mar 2025 00:12:38 +0100 Subject: [PATCH 7/7] Fix unit test CRLF support --- tests/RenderTest.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/RenderTest.php b/tests/RenderTest.php index a551736a..deb492b2 100644 --- a/tests/RenderTest.php +++ b/tests/RenderTest.php @@ -261,14 +261,13 @@ public function testFirstAndThirdColumnsSwappedWhenDirectionIsRtl(): void { $this->testParams["locale"] = "he"; $render = generateOutput($this->testStats, $this->testParams)["body"]; - $renderCollapsedSpaces = preg_replace("/(\s)\s*/", '$1', $render); - $this->assertStringContainsString( - "\n", - $renderCollapsedSpaces + $this->assertMatchesRegularExpression( + "/\\s*/", + $render ); - $this->assertStringContainsString( - "\n", - $renderCollapsedSpaces + $this->assertMatchesRegularExpression( + "/\\s*/", + $render ); }