From cc57a9f3474bff3cf3cdc3fd52d5a80fa4d45e9e Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh <77877486+everly-gif@users.noreply.github.com> Date: Wed, 1 Jun 2022 19:15:35 +0530 Subject: [PATCH] introduce formatting + linting in CONTRIBUTING.MD --- CONTRIBUTING.md | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae04e7732e..e1e0b868f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,18 +43,34 @@ $ git checkout -b [name_of_your_new_branch] ``` 3. Work - commit - repeat ( be sure to be in your branch ) -4. Push changes to GitHub +4. Before you push your changes, make sure your code follows the `PSR12` coding standards , which is the standard Appwrite follows currently. + You can easily do this by running the formatter +``` +./vendor/bin/phpcbf --standard=PSR12 +``` +This will format the code according to the `PSR12` coding standard. + +Now, go a step further by running the linter by the following command to manually fix the issues the formatter wasn't able to fix +``` +./vendor/bin/phpcs --standard=PSR12 +``` +This will give you a list of errors for you to rectify , if there is an instance you need more information on the errors being displayed you can pass in additional command line arguments. More list of available arguments can be found [here](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage). A very useful command line argument is `--report=diff`. This will give you the expected changes by the linter for easy fixing of formatting issues + +``` +./vendor/bin/phpcs --standard=PSR12 --report=diff +``` + +5. Push changes to GitHub ``` $ git push origin [name_of_your_new_branch] ``` - -5. Submit your changes for review -If you go to your repository on GitHub, you'll see a `Compare & pull request` button. Click on that button. -6. Start a Pull Request -Now submit the pull request and click on `Create pull request`. -7. Get a code review approval/reject -8. After approval, merge your PR -9. GitHub will automatically delete the branch after the merge is done. (they can still be restored). +6. Submit your changes for review +If you go to your repository on GitHub, you'll see a `Compare & pull request` button. Click on that button. +7. Start a Pull Request +Now submit the pull request and click on `Create pull request`. +8. Get a code review approval/reject +9. After approval, merge your PR +10. GitHub will automatically delete the branch after the merge is done. (they can still be restored). ## Setup From Source @@ -96,7 +112,7 @@ We love to create issues that are good for beginners and label them as `good fir ##### Tools and Libs - [Docker](https://www.docker.com/get-started) -- [PHP FIG](https://www.php-fig.org/) - [PSR-1](https://www.php-fig.org/psr/psr-1/) and [PSR-4](https://www.php-fig.org/psr/psr-4/) +- [PHP FIG](https://www.php-fig.org/) - [PSR-12](https://www.php-fig.org/psr/psr-12/) - [PHP Swoole](https://www.swoole.co.uk/) Learn more at our [Technology Stack](#technology-stack) section. @@ -224,7 +240,7 @@ Appwrite uses [PHP's Composer](https://getcomposer.org/) for managing dependenci ## Coding Standards -Appwrite is following the [PHP-FIG standards](https://www.php-fig.org/). Currently, we are using both PSR-0 and PSR-4 for coding standards and autoloading standards. Soon we will also review the project for support with PSR-12 (Extended Coding Style). +Appwrite is following the [PHP-FIG standards](https://www.php-fig.org/). Currently, we are using _PSR-12_ for coding standards and autoloading standards. We use prettier for our JS coding standards and auto-formatting our code.