diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..f14aa549 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +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 +indent_size = 2 + +[*.{js,css}] +indent_size = 2 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/.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/.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/ diff --git a/.prettierignore b/.prettierignore index 22d0d82f..b7c990df 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..2a1fc68e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "printWidth": 120, + "endOfLine": "auto" +} \ No newline at end of file diff --git a/composer.json b/composer.json index 82a95b97..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": "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": "npx prettier --check *.md **/*.{php,md,js,css}", + "lint-fix": "npx 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" } } 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 ); }