Skip to content

Add prettier for code formatting #89

Open
@gr2m

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions