Lissy93 / personal-security-checklist

🔒 A compiled checklist of 300+ tips for protecting digital security and privacy in 2024
https://digital-defense.io
Other
16.71k stars 1.16k forks source link

Consider adding package.json + prettier for contributing #106

Open lukecarr opened 2 years ago

lukecarr commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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/prettier_action@v4.2
        with:
          prettier_options: --write **/*.md *.md
          only_changed: True
Lissy93 commented 2 years ago

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