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 to codebase #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add Prettier to codebase #2

wants to merge 3 commits into from

Conversation

ahlec
Copy link
Contributor

@ahlec ahlec commented Jul 15, 2023

This PR is focused on adding a code formatter, bringing all of the existing code into compliance with the formatter, and then adding a validation workflow to ensure future code is all formatted correctly too.

Notes:

  • I've added an empty "prettier": {} to the package.json file in order to support IDEs that are set up to only format if the repository is configured with Prettier
    • In VS Code (using the official Prettier plugin), this is the Prettier: Require Config setting
    • For these IDEs, the existence of Prettier in node_modules isn't enough; you need to have it explicitly "turned on," so I've turned it on without overriding any of the values
  • I had Prettier skip over two directories for now:
    • .next is a local compile cache, so we get nothing from formatting it
    • @types is where we currently store our GraphQL codegen files. Codegen recommends against running the output through formatters in a second pass — if you're going to format it, it should be part of the codegen process itself, rather than something afterwards
    • This blocklist also already inherits from the default Prettier .prettierignore, meaning that it's also skipping node_modules/ and .git, etc.
  • The PR validation workflow is a relatively simple/straightforward version right now. I've put it through a couple of tests on my fork to ensure it works:
    • Workflow passes (and caches correctly) when all files are in compliance: here
    • Workflow fails when one or more files isn't formatted: here
    • Workflow restores from an older cache when we don't have a direct cache hit: here

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

Successfully merging this pull request may close these issues.

1 participant