0

Not sure why in my setup, every time I do

npm version patch

It will auto reformat all my typescript source code. This is very annoying as the style is totally not what I preferred. I have to manually revert the format. How can I avoid it from reformatting?

Here is the console output for the command, I can see the annoying "prettier" is triggered.

npm version patch

> treedoc@0.2.1 preversion /Users/jianwche/opensource/treedoc_ts
> npm run lint


> treedoc@0.2.0 lint /Users/jianwche/opensource/treedoc_ts
> tslint -p tsconfig.json

v0.2.1

> treedoc@0.2.1 version /Users/jianwche/opensource/treedoc_ts
> npm run format && git add -A src


> treedoc@0.2.1 format /Users/jianwche/opensource/treedoc_ts
> prettier --write "src/**/*.ts" "src/**/*.js"

Here are my package scripts:

{
  scripts: {
    "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
    "version": "npm run format && git add -A src",
  }
}
Edric
  • 24,639
  • 13
  • 81
  • 91
Jianwu Chen
  • 5,336
  • 3
  • 30
  • 35
  • You probably need to put the `scripts` section of your `package.json` in the question, you have some category of version hooks running. – Tibrogargan Jul 09 '20 at 03:57

1 Answers1

0

Seems it's my fault, the template I used to create the project seems automatically add the "format" command in the "version" script in the package.json. I solved this issue by removing it.

Updated package.json:

{
  scripts: {
    "version": "npm run format && git add -A src",
  }
}
Edric
  • 24,639
  • 13
  • 81
  • 91
Jianwu Chen
  • 5,336
  • 3
  • 30
  • 35