|
2 | 2 |
|
3 | 3 | # Prettier for Code Formatting |
4 | 4 |
|
5 | | -[Prettier](https://prettier.io/) is an opinionated code formatter that enforces a consistent code style across the entire project. This repository is configured to use Prettier in two ways: automatically via a GitHub workflow and manually for local development. |
| 5 | +[Prettier](https://prettier.io/) is an opinionated code formatter that enforces a consistent code style across the entire project. This repository uses Prettier in two ways: |
6 | 6 |
|
7 | | -## Automated Formatting with GitHub Actions |
| 7 | +- A **linting check** that runs automatically on pull requests to verify formatting. |
| 8 | +- A **manual workflow** that can be run to format the entire repository. |
8 | 9 |
|
9 | | -This repository includes a [GitHub Actions workflow](./workflows.prettier.md) that automatically formats all code. |
| 10 | +## Linting with GitHub Actions |
10 | 11 |
|
11 | | -- **How it works**: The workflow runs on every push to the `main` branch and on every pull request. It runs `prettier --write .` to format all files and commits any changes with the message "style: Format code with Prettier". |
12 | | -- **What you need to do**: Nothing! The workflow handles everything automatically. If you push code that isn't formatted, the workflow will create a new commit with the required formatting changes. |
| 12 | +This repository includes a [CI workflow](./workflows.ci.md) that automatically checks for formatting issues on every pull request. |
13 | 13 |
|
14 | | -This ensures that all code merged into the `main` branch is consistently formatted. |
| 14 | +- **How it works**: The workflow runs `prettier --check .`. If it finds any files that are not correctly formatted, the workflow will fail. This prevents code with incorrect formatting from being merged. |
| 15 | +- **What you need to do**: Make sure to run Prettier on your code before pushing it. If the check fails, you will need to format your code and push the changes. |
| 16 | + |
| 17 | +## Manual Formatting Workflow |
| 18 | + |
| 19 | +For convenience, this repository also includes a [manual formatting workflow](./workflows.prettier.md) that you can trigger from the Actions tab in GitHub. |
| 20 | + |
| 21 | +- **How it works**: This workflow runs `prettier --write .` on all files and commits any changes back to your branch. |
| 22 | +- **When to use it**: You can use this if you forget to format your code locally, or if you want to format a large number of files at once. |
15 | 23 |
|
16 | 24 | ## Manual Formatting |
17 | 25 |
|
@@ -39,6 +47,5 @@ You can run Prettier from the command line to format your files. |
39 | 47 | ```bash |
40 | 48 | npx prettier . --check |
41 | 49 | ``` |
42 | | - The [CI workflow](./workflows.ci.md) uses this command to validate formatting on pull requests. |
43 | 50 |
|
44 | 51 | For more detailed information on using Prettier, refer to the [official Prettier documentation](https://prettier.io/docs/en/). |
0 commit comments