Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 210
RRP Avatar asked Apr 09 '26 22:04

RRP


1 Answers

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

You have:

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

Instead, remove the space in the pattern as follows:

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

like image 131
Duke Avatar answered Apr 12 '26 11:04

Duke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!