Skip to content

Commit

Permalink
Added guidelines for code formatting on save (#175)
Browse files Browse the repository at this point in the history
* Add code formatting guidelines

* Update code formatting instructions in documentation

* Added category name of Source Code

* Update docs/manual/98_contributing/05_source/60_codeFormatting.md

Co-authored-by: Armando Salazar <[email protected]>

* Update docs/manual/98_contributing/05_source/index.md

Co-authored-by: Armando Salazar <[email protected]>

---------

Co-authored-by: hanzlamateen <[email protected]>
Co-authored-by: Armando Salazar <[email protected]>
  • Loading branch information
3 people authored May 24, 2024
1 parent adb6f2a commit 5135342
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/manual/98_contributing/05_source/60_codeFormatting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Code Formatting

Prettier helps us maintain consistent code formatting across our projects.

## Setting up Prettier in VS Code

### Step 1. Install the Prettier Extension
1. Press `Ctrl` + `P` to open the command palette.
2. Type `ext install esbenp.prettier-vscode` and press `Enter`.
3. Follow the prompts to install the Prettier extension.

### Step 2. Open VS Code Settings
Press `Ctrl` + `,` together to open the VS Code settings.

### Step 3. Enable Format on Save
1. In the search bar at the top, type `Format on Save`.
2. You will see three tabs: **User**, **Remote**, and **Workspace**.
3. Check the box next to **Editor: Format on Save** under the User and Remote tabs.

:::note
Do not check the box under the **Workspace** tab.
:::

### Step 4. Set Prettier as the Default Formatter
1. Open any file in your workspace.
2. Right-click within the file editor.
3. Select **Format Document With...**.
4. Choose **Configure Default Formatter...**.
5. Select **Prettier - Code Formatter** from the list.



## Verifying Your Setup

To ensure code is automatically formatted upon saving:
1. Open a file with some unformatted code.
2. Make a small edit and save the file (`Ctrl` + `S`).
3. Check if the code is automatically formatted upon saving.

By following these steps, you ensure that Prettier is set up as the default code formatter and that formatting occurs automatically on save, reducing formatting issues across the team.
1 change: 1 addition & 0 deletions docs/manual/98_contributing/05_source/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
position: 6
7 changes: 7 additions & 0 deletions docs/manual/98_contributing/05_source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import DocCardList from '@theme/DocCardList'

# Source Code

This section contains coding standards that help you effectively contribute to the engine's source code.

<DocCardList />

0 comments on commit 5135342

Please sign in to comment.