Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added guidelines for code formatting on save #175

Merged
merged 8 commits into from
May 24, 2024
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

Check warning on line 1 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Headings] 'Code Formatting' should use sentence-style capitalization. Raw Output: {"message": "[Microsoft.Headings] 'Code Formatting' should use sentence-style capitalization.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 1, "column": 3}}}, "severity": "INFO"}

Prettier helps us maintain consistent code formatting across our projects.

Check warning on line 3 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.We] Try to avoid using first-person plural like 'us'. Raw Output: {"message": "[Microsoft.We] Try to avoid using first-person plural like 'us'.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 3, "column": 16}}}, "severity": "WARNING"}

Check warning on line 3 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.ComplexWords] Consider using 'keep' or 'support' instead of 'maintain'. Raw Output: {"message": "[Microsoft.ComplexWords] Consider using 'keep' or 'support' instead of 'maintain'.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 3, "column": 19}}}, "severity": "INFO"}

Check warning on line 3 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.We] Try to avoid using first-person plural like 'our'. Raw Output: {"message": "[Microsoft.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 3, "column": 62}}}, "severity": "WARNING"}

## Setting up Prettier in VS Code

Check warning on line 5 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading. Raw Output: {"message": "[Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 5, "column": 27}}}, "severity": "WARNING"}

### Step 1. Install the Prettier Extension

Check warning on line 7 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Headings] 'Step 1. Install the Prettier Extension' should use sentence-style capitalization. Raw Output: {"message": "[Microsoft.Headings] 'Step 1. Install the Prettier Extension' should use sentence-style capitalization.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 7, "column": 5}}}, "severity": "INFO"}
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

Check warning on line 12 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Headings] 'Step 2. Open VS Code Settings' should use sentence-style capitalization. Raw Output: {"message": "[Microsoft.Headings] 'Step 2. Open VS Code Settings' should use sentence-style capitalization.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 12, "column": 5}}}, "severity": "INFO"}

Check warning on line 12 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading. Raw Output: {"message": "[Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 12, "column": 18}}}, "severity": "WARNING"}
Press `Ctrl` + `,` together to open the VS Code settings.

### Step 3. Enable Format on Save

Check warning on line 15 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Headings] 'Step 3. Enable Format on Save' should use sentence-style capitalization. Raw Output: {"message": "[Microsoft.Headings] 'Step 3. Enable Format on Save' should use sentence-style capitalization.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 15, "column": 5}}}, "severity": "INFO"}
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.

Check failure on line 21 in docs/manual/98_contributing/05_source/60_codeFormatting.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Contractions] Use 'don't' instead of 'Do not'. Raw Output: {"message": "[Microsoft.Contractions] Use 'don't' instead of 'Do not'.", "location": {"path": "docs/manual/98_contributing/05_source/60_codeFormatting.md", "range": {"start": {"line": 21, "column": 4}}}, "severity": "ERROR"}
:::

### 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.

Check warning on line 5 in docs/manual/98_contributing/05_source/index.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.ComplexWords] Consider using 'has' instead of 'contains'. Raw Output: {"message": "[Microsoft.ComplexWords] Consider using 'has' instead of 'contains'.", "location": {"path": "docs/manual/98_contributing/05_source/index.md", "range": {"start": {"line": 5, "column": 14}}}, "severity": "INFO"}

<DocCardList />
Loading