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

Consider adding package.json + prettier for contributing #106

Open
lukecarr opened this issue Apr 4, 2022 · 3 comments
Open

Consider adding package.json + prettier for contributing #106

lukecarr opened this issue Apr 4, 2022 · 3 comments

Comments

@lukecarr
Copy link
Contributor

lukecarr commented Apr 4, 2022

I already have a PR ready to go, but thought an issue could better serve as a discussion before opening!

I think it goes without saying that consistent and reproducible formatting on any project (especially one this popular) is always welcome.

I noticed in the ATTRIBUTIONS.md that you're (most likely) using a local installation of Prettier (<!-- prettier-ignore-start -->). I think that adding a very minimal package.json with a pinned Prettier version included as a devDep could improve contributability(?).

However, I've scanned the existing Markdown source with Prettier and there were quite a few recommendations for each file, so I'd be curious to know if you're using a customised config locally, or not using it at all (and the ignore tags I found are ancient relics)!

@Lissy93
Copy link
Owner

Lissy93 commented Apr 4, 2022

I did try using something a while back, but the problem was managing PRs. I wanted to keep things easy for contributors, without them having to install and run stuff locally. This was before GitHub actions came about, so I could revisit this now, and have a style guide that runs when a PR is opened, maybe with issues being either auto-fixed, or added as a comment on the PR

@lukecarr
Copy link
Contributor Author

lukecarr commented Apr 4, 2022

I wanted to keep things easy for contributors, without them having to install and run stuff locally.

That makes perfect sense.

Admittedly I've never used Prettier in a GitHub action to actually make changes, only to check and reject/accept PRs.

It looks like the prettier-action can do all of that. Probably would be sensible (and marginally more performant) to use only_changed so it will skip linting unmodified files. (Although this means you probably want to do a one-off, manual commit to lint the existing source.

Something like:

name: Continuous Integration

on:
  pull_request:
    branches: [master]

jobs:
  prettier:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
          fetch-depth: 0

      - name: Prettify code
        uses: creyD/[email protected]
        with:
          prettier_options: --write **/*.md *.md
          only_changed: True

@Lissy93
Copy link
Owner

Lissy93 commented Apr 4, 2022

Awesome, thanks for snippet. I'll try this out this evening and hopefully get a proper styleguide implemented :)

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

2 participants