Nodejs.dev: Add prettier to husky hooks?

Created on 3 Mar 2019  路  6Comments  路  Source: nodejs/nodejs.dev

While trying "format" script locally when working on #162, the script picked up some code format updates. That led my curiosity to audit the husky config in package.json:

"husky": {
    "hooks": {
      "commit-msg": "commitlint --edit $HUSKY_GIT_PARAMS"
    }
  }

Would you think that it'd be productive to add prettier to the husky pre-commit hooks to check code format?

Most helpful comment

... You push code with changes which you don't see.

@LaRuaNa, +1 鈽濓笍 reason not to commit format update in pre-push.

So all in all: pre push --check 鉁旓笍

After reviewing #97, there are "format-check" and "tslint" scripts that pre-push hook can potentially use those scripts to just run check on code format but not commit anything. I can look out for the merge of #97, and then follow up with a simple PR for pre-push check.

All 6 comments

Sounds like a good idea.

I feel adding prettier to pre-commit hooks will slow down developer velocity.

Adding it to a pre-push hook would be more acceptable. Most developers use commit far more frequently than push. This way, prettier runs only once when pushing rather than on every commit which can get annoying.

@sagirk, pre-push hook does sound more acceptable to gate-check code format. Ditto pre-push option.

We can add a "--check" but automatically pre push or commit format is quite bad practice. You push code with changes which you don't see. I'm working on a PR to integrate linter + prettier. I think we'll need to change or rethink or rules anyways :]

So all in all: pre push --check 鉁旓笍

We can add a "--check" but automatically pre push or commit format is quite bad practice. You push code with changes which you don't see. I'm working on a PR to integrate linter + prettier. I think we'll need to change or rethink or rules anyways :]

So all in all: pre push --check 鉁旓笍

Yup. Sounds far more reasonable. 馃挴 馃憤

... You push code with changes which you don't see.

@LaRuaNa, +1 鈽濓笍 reason not to commit format update in pre-push.

So all in all: pre push --check 鉁旓笍

After reviewing #97, there are "format-check" and "tslint" scripts that pre-push hook can potentially use those scripts to just run check on code format but not commit anything. I can look out for the merge of #97, and then follow up with a simple PR for pre-push check.

Was this page helpful?
0 / 5 - 0 ratings