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

Add prettier for code formatting #89

Open
gr2m opened this issue Sep 13, 2024 · 0 comments
Open

Add prettier for code formatting #89

gr2m opened this issue Sep 13, 2024 · 0 comments

Comments

@gr2m
Copy link
Collaborator

gr2m commented Sep 13, 2024

Now that the number of contributors is growing, I'd like to introduce prettier for code formatting

Here is the syntax I usually use. I don't want us to customize prettier rules. That way people can get mad at prettier and not us if they don't like any of the formatting 🤣

https://github.com/gr2m/github-app-slack-demo/blob/47fc915ff72c7b0a3e4f9b26761c18c303cd5152/package.json#L15

I don't want to add it to our CI and bother our contributors. Instead, we can silently fix formatting directly in the main branch using a dedicated app later. I'll take care of that once this issue is resolved. But in a nutshell

  1. Register a single purpose GitHub app with contents:write permission, webhooks disabled.
  2. Install the app on this repository
  3. Add the App ID as variable and private key as secret to this repository
  4. Create a new workflow that is triggered by push to main
    1. Use https://github.com/actions/create-github-app-token to create an installation access token
    2. Use that token to check out the repository
    3. run the lint:fix npm script
    4. Commit the changes (if any) with style: prettier and push them
  5. Using repository rules, add the registered github app to the allowed actors that can bypass branch protections
  6. Profit 🎉

Here is a format.yml workflow for reference:
https://github.com/gr2m/github-app-slack-demo/blob/47fc915ff72c7b0a3e4f9b26761c18c303cd5152/.github/workflows/format.yml

gr2m pushed a commit that referenced this issue Sep 18, 2024
### Description
- **build(prettier): run Prettier for missing files of the project**
- **style(prettier): run Prettier format**

<!--
This pull request template provides suggested sections for framing your
work.
You're welcome to change or remove headers if it doesn't fit your use
case. :)
-->

### Context
Relates to #89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant