From c1dda58fb5baa569ff61119286e49629b0e7a954 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:05:06 -0600 Subject: [PATCH 01/14] [Test PR] style: remove newline from index.php --- src/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.php b/src/index.php index 58367637..ea723508 100644 --- a/src/index.php +++ b/src/index.php @@ -8,7 +8,6 @@ require_once "card.php"; // load .env - $dotenv = \Dotenv\Dotenv::createImmutable(dirname(__DIR__, 1)); $dotenv->safeLoad(); From d29731e8420cb669322ea33afd74603b3cd69ada Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:08:35 -0600 Subject: [PATCH 02/14] test prettier --- src/index.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.php b/src/index.php index ea723508..1443ad40 100644 --- a/src/index.php +++ b/src/index.php @@ -13,9 +13,7 @@ // if environment variables are not loaded, display error if (!isset($_SERVER["TOKEN"])) { - $message = file_exists(dirname(__DIR__ . "../.env", 1)) - ? "Missing token in config. Check Contributing.md for details." - : ".env was not found. Check Contributing.md for details."; + $message = file_exists(dirname(__DIR__ . "../.env", 1)) ? "Missing token in config. Check Contributing.md for details." : ".env was not found. Check Contributing.md for details."; renderOutput($message, 500); } From 50df0757cfac0909c681fe8b4abeea423d7a6880 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:14:54 -0600 Subject: [PATCH 03/14] remove head ref --- .github/workflows/prettier.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index b2d8d465..0deac4cb 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -24,4 +24,3 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: "style: Formatted code with Prettier" - branch: ${{ github.head_ref }} From 8ee8d359b6bed61eb521655eb71d354842925dd4 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:17:20 -0600 Subject: [PATCH 04/14] Update prettier.yml --- .github/workflows/prettier.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 0deac4cb..5ff878ec 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -12,7 +12,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} - name: Install prettier and plugin-php run: npm install --global prettier @prettier/plugin-php From 8f4eed4c632b250bf77872361d9a36037067dad6 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:29:30 -0600 Subject: [PATCH 05/14] Update prettier.yml --- .github/workflows/prettier.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 5ff878ec..85722f95 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,20 +1,22 @@ name: Format with Prettier on: - pull_request: push: branches: - main + pull_request: + paths: + - "**.php" + - "**.md" + - "**.js" + - "**.css" jobs: prettier: runs-on: ubuntu-latest - steps: - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} + uses: actions/checkout@v3 - name: Install prettier and plugin-php run: npm install --global prettier @prettier/plugin-php @@ -23,6 +25,7 @@ jobs: run: composer lint-fix - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: EndBug/add-and-commit@v7 with: - commit_message: "style: Formatted code with Prettier" + message: "style: Formatted code with Prettier" + default_author: github_actions From 658a56628dbad80ae74ec0a05c55991825d33f79 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:32:06 -0600 Subject: [PATCH 06/14] Update prettier.yml --- .github/workflows/prettier.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 85722f95..17632aed 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -16,7 +16,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v2 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} - name: Install prettier and plugin-php run: npm install --global prettier @prettier/plugin-php @@ -25,7 +28,7 @@ jobs: run: composer lint-fix - name: Commit changes - uses: EndBug/add-and-commit@v7 + uses: EndBug/add-and-commit@v9 with: message: "style: Formatted code with Prettier" default_author: github_actions From 30a7b9081812546aca2646b6c96ce2f6cf06fab9 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:35:23 -0600 Subject: [PATCH 07/14] Update prettier.yml --- .github/workflows/prettier.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 17632aed..5ee5b13f 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -15,12 +15,17 @@ jobs: prettier: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout Pull Request + if: ${{ github.event_name == 'pull_request' }} + uses: actions/checkout@v3 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - name: Checkout Push + if: ${{ github.event_name != 'pull_request' }} + uses: actions/checkout@v3 + - name: Install prettier and plugin-php run: npm install --global prettier @prettier/plugin-php From 3088a019962570a2261e442b7d32363463a0c3fd Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:36:32 -0600 Subject: [PATCH 08/14] style: format with prettier --- src/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.php b/src/index.php index 1443ad40..ea723508 100644 --- a/src/index.php +++ b/src/index.php @@ -13,7 +13,9 @@ // if environment variables are not loaded, display error if (!isset($_SERVER["TOKEN"])) { - $message = file_exists(dirname(__DIR__ . "../.env", 1)) ? "Missing token in config. Check Contributing.md for details." : ".env was not found. Check Contributing.md for details."; + $message = file_exists(dirname(__DIR__ . "../.env", 1)) + ? "Missing token in config. Check Contributing.md for details." + : ".env was not found. Check Contributing.md for details."; renderOutput($message, 500); } From ae253cb2e30d86fbdf158dbfb12a8b7f706fbad6 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:52:05 -0600 Subject: [PATCH 09/14] check readme, ignore vendor --- .github/workflows/prettier.yml | 3 +++ .prettierignore | 1 + composer.json | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .prettierignore diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 5ee5b13f..a64c2515 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -29,6 +29,9 @@ jobs: - name: Install prettier and plugin-php run: npm install --global prettier @prettier/plugin-php + - name: Show files needed to fix + run: composer lint + - name: Prettify code run: composer lint-fix diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..22d0d82f --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +vendor diff --git a/composer.json b/composer.json index 8f5e3f9e..16c733b4 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 **/*.{php,md,js,css} !**/*.min.js --print-width 120", - "lint-fix": "prettier --write **/*.{php,md,js,css} !**/*.min.js --print-width 120" + "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" } } \ No newline at end of file From 2c6c5a6d99b6b166d62578d25c7aa405c8844df2 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:53:25 -0600 Subject: [PATCH 10/14] test prettier --- src/index.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.php b/src/index.php index ea723508..1443ad40 100644 --- a/src/index.php +++ b/src/index.php @@ -13,9 +13,7 @@ // if environment variables are not loaded, display error if (!isset($_SERVER["TOKEN"])) { - $message = file_exists(dirname(__DIR__ . "../.env", 1)) - ? "Missing token in config. Check Contributing.md for details." - : ".env was not found. Check Contributing.md for details."; + $message = file_exists(dirname(__DIR__ . "../.env", 1)) ? "Missing token in config. Check Contributing.md for details." : ".env was not found. Check Contributing.md for details."; renderOutput($message, 500); } From 6b618a7b23357c2ad8a565736daaba2fa22410df Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:57:40 -0600 Subject: [PATCH 11/14] Document linting --- .github/workflows/prettier.yml | 2 +- CONTRIBUTING.md | 12 ++++++++++++ src/index.php | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index a64c2515..6d3254ba 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -29,7 +29,7 @@ jobs: - name: Install prettier and plugin-php run: npm install --global prettier @prettier/plugin-php - - name: Show files needed to fix + - name: Lint with Prettier run: composer lint - name: Prettify code diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66201c5f..ce66098d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,6 +86,18 @@ Run the following command to run the PHPUnit test script which will verify that composer test ``` +## Linting + +This project uses Prettier for formatting of PHP, Markdown, JavaScript and CSS files. + +```bash +# Run prettier and show the files that need to be fixed +composer lint + +# Run prettier and fix the files +composer lint-fix +``` + ## Submitting Contributions 👨‍💻 Below you will find the process and workflow used to review and merge your changes. diff --git a/src/index.php b/src/index.php index 1443ad40..ea723508 100644 --- a/src/index.php +++ b/src/index.php @@ -13,7 +13,9 @@ // if environment variables are not loaded, display error if (!isset($_SERVER["TOKEN"])) { - $message = file_exists(dirname(__DIR__ . "../.env", 1)) ? "Missing token in config. Check Contributing.md for details." : ".env was not found. Check Contributing.md for details."; + $message = file_exists(dirname(__DIR__ . "../.env", 1)) + ? "Missing token in config. Check Contributing.md for details." + : ".env was not found. Check Contributing.md for details."; renderOutput($message, 500); } From 078b857142a697a513d73678e25beb164cd8bd6c Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 10:58:25 -0600 Subject: [PATCH 12/14] docs --- CONTRIBUTING.md | 2 +- README.md | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ce66098d..b109436f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,7 +88,7 @@ composer test ## Linting -This project uses Prettier for formatting of PHP, Markdown, JavaScript and CSS files. +This project uses Prettier for formatting PHP, Markdown, JavaScript and CSS files. ```bash # Run prettier and show the files that need to be fixed diff --git a/README.md b/README.md index e11e261a..9536c2c8 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,19 @@ Run the following command to run the PHPUnit test script which will verify that composer test ``` + +### Linting + +This project uses Prettier for formatting PHP, Markdown, JavaScript and CSS files. + +```bash +# Run prettier and show the files that need to be fixed +composer lint + +# Run prettier and fix the files +composer lint-fix +``` + ## 🙋‍♂️ Support 💙 If you like this project, give it a ⭐ and share it with friends! From fa8c9bb5828c197bd27412af560c73c9479b9209 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 11:01:59 -0600 Subject: [PATCH 13/14] Update prettier.yml --- .github/workflows/prettier.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 6d3254ba..8b043291 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -30,6 +30,7 @@ jobs: run: npm install --global prettier @prettier/plugin-php - name: Lint with Prettier + continue-on-error: true run: composer lint - name: Prettify code From d4f02980e9896d8419c9cdab925eff709e890c0a Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 12 Aug 2022 11:03:51 -0600 Subject: [PATCH 14/14] style: fix with prettier --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9536c2c8..ad4a6a95 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,6 @@ Run the following command to run the PHPUnit test script which will verify that composer test ``` - ### Linting This project uses Prettier for formatting PHP, Markdown, JavaScript and CSS files.