chooser icon indicating copy to clipboard operation
chooser copied to clipboard

[Feature] enable Prettier to run automatically

Open dijitali opened this issue 10 months ago • 0 comments

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).

  • #507
  • #351

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.

  • #468

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

  • [x] I would be interested in implementing this feature.

dijitali avatar Apr 05 '24 07:04 dijitali