简体   繁体   中英

Prettier format a json file

I have a unformatted json file that gets stored in my application with the following structure

src
 /forms
   /test
     - abc.json

I am using husky and lint-staged to make use of prettier and linting on pre-commit. The configuration resides in my package.json as following

  "husky": {
    "hooks": {
      "pre-commit": "lint-staged --relative",
      "pre-push": "tsc"
    }
  },
  "lint-staged": {
    "src/**/*.{ts, json}": [
      "prettier --write",
      "eslint --fix"
    ]
  },
  ....
  ..

But for some reason the abc.json file never gets formatted when I push my code to github. What am I missing?

There's an error in your glob pattern. Patterns within curly braces should only be delimited by a comma

You have:

"src/**/*.{ts, json}" \

It should be:

"src/**/*.{ts,json}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM