ucsc / ucsc-2022

Official WordPress theme for UC Santa Cruz
6 stars 0 forks source link

Herm71/issue23 #142

Closed Herm71 closed 1 year ago

Herm71 commented 1 year ago

Add Husky, lint-staged, prettier and @wordpress/prettier-config to package.json. Fixes #23

knice commented 1 year ago

@Herm71, a few notes on package.json:

  1. The result of npx husky-init (a .husky folder with a pre-commit hook script file in it) will already be in the codebase after this PR is merged. So it is redundant and unnecessary to run it again as a postinstall npm script. It also requires user confirmation to proceed (it asks to install husky-init).

The script you have in prepare, (husky install) is required for anyone downloading this repo to do development work.

So it seems like you can remove the prepare script and make the postinstall script husky install. Then you aren't running any scripts that aren't required. This is important for when we add CI/automated testing.

  1. lint-php should be lint:php since that is the common syntax for NPM scoped scripts.
  2. The output of the npm script prettier just dumped the contents of the scss/css files it evaluated into my terminal window. Is that script supposed to do something different?
  3. We have a lot in the scripts object now. Order them alphabetically so it's easier to read through them.
  4. Update the homepage object as well.
Herm71 commented 1 year ago

@knice, in response to your comments in the list above, and based on our earlier discussion:

  1. The postinstall script has been changed to "postinstall": "npx husky install". Please note the necessary addition of npx in the command.
  2. PHP linting scripts have been removed from the lint-staged.config.js and any php-linting scripts have been removed from package.json. PHPCodeSniffer can still be run individual files via the composer scripts.
  3. All Prettier scripts have been removed from the "scripts" object of the package.json file; however, as discussed, it remains as a development dependency and the "prettier": "@wordpress/prettier-config", object remains in the package.json file. This means, like PHPCodeSniffer, Prettier can still be run on individual files using npx and it will adhere to WordPress standards. This can be used in conjunction with the @wp-scripts' "lint:style": "wp-scripts lint-style" script to lint CSS and SCSS files.
    Finally, staged CSS and SCSS files will be run against "lint:style": "wp-scripts lint-style" via lint-staged.config.js
  4. Scripts in package.json have been ordered alphabetically
  5. The homepage object has been updated with the correct URL.
Herm71 commented 1 year ago

@knice, based on our recent conversation,

  1. npx has been removed from the "postinstall" and "test" scripts. This has been tested and works
  2. The "release" script has been alphabetized appropriately
  3. The url in the "bugs" object in the package.json file has been corrected.

I've re-cloned and rebuilt with these changes and all works properly.