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-mit. The configuration resides in my package.json
as following
"husky": {
"hooks": {
"pre-mit": "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?
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-mit. The configuration resides in my package.json
as following
"husky": {
"hooks": {
"pre-mit": "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?
-
Do your .ts files get formatted? I think the glob pattern is
src/**/\*.{ts, json}
instead ofsrc/**/*.{ts, json}
– Tyress Commented Jan 7, 2022 at 1:27 - 1 @Tyress yes the .ts files gets formatted – RRP Commented Jan 7, 2022 at 1:33
-
@RRP Did you at all try removing src and considering all ts and json files for formatting ?
**/*.{ts,json,}
– Vipulw Commented Jan 15, 2022 at 10:46 - @Vipulw yep tried that as well still no luck, the .json file just doesn't get formatted – RRP Commented Jan 16, 2022 at 23:46
-
@RRP what is the parser defined in
.prettierrc
? – Ben Commented Jun 6, 2022 at 8:57
1 Answer
Reset to default 3There's an error in your glob pattern. Patterns within curly braces should only be delimited by a ma
You have:
"src/**/*.{ts, json}"
Instead, remove the space in the pattern as follows:
"src/**/*.{ts,json}"