creativecommons / chooser

The new and improved CC license selection tool.
https://chooser-beta.creativecommons.org
MIT License
97 stars 124 forks source link

[Feature] enable Prettier to run automatically #520

Open dijitali opened 3 months ago

dijitali commented 3 months ago

Problem

I noticed when working on #507 that although this repository has the Prettier formatter enabled (since #351), it doesn't appear to be run automatically and so creates confusion when a contributor uses an IDE that does automatically apply the existing Prettier config (I believe I ran into it because of using VSCode with the official Prettier extension installed).

Description

My suggestion would be to enable Prettier via a pre-commit hook using Husky as recommended here.

If desired, prettier . --check could also be run in GitHub Actions, as suggested in Prettier docs.

I would also suggest re-adding the eslint-config-prettier package to ensure ESLint and Prettier play nicely. It appears to have been removed to reduce the build size in #468 but, since it's a devDependency, it won't affect the production build size.

Alternatives

Leave it as is and remove Prettier config, however it seems like the use of Prettier is one of the CC javascript guidelines.

Additional context

There is already something here that appears to relate to pre-commit hooks. I'm not sure what that configures, potentially the git-hooks package, but that isn't installed and also doesn't appear as actively maintained or widely used as Husky:

https://github.com/creativecommons/chooser/blob/53599209e9e0df9d656c2037946207978cf6ee11/package.json#L82-L84

Implementation