Closed joshwooding closed 6 months ago
I can confirm this issue as well
Yes it breaks
/pretty-quick/dist/isSupportedExtension.js:12
..._prettier.resolveConfig.sync(file, {
^
TypeError: _prettier.resolveConfig.sync is not a function
mark
Just experienced this too.
Same problem
Dependabot / Renovate bots mean this is going to hit a lot of people now when they rebase and try and commit.
Joining the club. Experiencing same problem
We had the same issue - the solution was to switch back to lint-staged, as described in: https://prettier.io/docs/en/precommit.html
You didn't have the same problem?
The issue seems to be with Prettier v3.
I tried switching to Lint-staged and it also doesn't seem to be happy with Prettier v3.
My fix for now is to stick with Prettier v2.8.8
interesting - after following the https://github.com/okonet/lint-staged#installation-and-setup for lint-staged it seems to be working, I don't have any issues with prettier@3
imho it makes sense because lint-staged makes it possible to run anything: i.e. just "prettier" command, it doesn't rely on any prettier internals (like pretty-quick does)
I'll give it another try. I did give up on troubleshooting pretty quick :P
Seems the library is not maintained? How about forking and fixing?
Seems the library is not maintained?
Maybe it still is? It could be that the author @azz only needs more time and prioritises this? 🤞 🙏 😇
Threw together #165 as a first attempt at supporting 3.0. I don't know if those changes are 100%, nor if they will still work with 2.x, but it's a start
The last release was more than 1.5 years ago, the lint-staged package is a viable alternative that supports prettier v3 already: https://github.com/okonet/lint-staged
If you are using npx
you can just use something like:
npx -p prettier@^2 -p pretty-quick pretty-quick
Dependabot / Renovate bots mean this is going to hit a lot of people now when they rebase and try and commit.
Yep, this happened to me.
Same here :(
> pretty-quick --staged --pattern "src/**/*.ts"
🔍 Finding changed files since git revision 83ec8716.
C:\git\projects\server\node_modules\.pnpm\pretty-quick@3.1.3_prettier@3.0.0\node_modules\pretty-quick\dist\isSupportedExtension.js:12
..._prettier.resolveConfig.sync(file, {
^
TypeError: _prettier.resolveConfig.sync is not a function
at C:\git\projects\server\node_modules\.pnpm\pretty-quick@3.1.3_prettier@3.0.0\node_modules\pretty-quick\dist\isSupportedExtension.js:12:30
at Array.filter (<anonymous>)
at _default (C:\git\projects\server\node_modules\.pnpm\pretty-quick@3.1.3_prettier@3.0.0\node_modules\pretty-quick\dist\index.js:53:157)
at Object.<anonymous> (C:\git\projects\server\node_modules\.pnpm\pretty-quick@3.1.3_prettier@3.0.0\node_modules\pretty-quick\bin\pretty-quick.js:17:27)
at Module._compile (node:internal/modules/cjs/loader:1267:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
at Module.load (node:internal/modules/cjs/loader:1125:32)
at Module._load (node:internal/modules/cjs/loader:965:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.0.0
ELIFECYCLE Command failed with exit code 1.
husky - pre-commit hook exited with code 1 (error)
Or without pretty-quick, replacing the line in Husky(other task runners are available)'s ./.husky/pre-commit
with...
LIST=`git diff-index --name-only --cached HEAD`; if [ "$LIST" ]; then npx prettier --write $LIST; git add $LIST; fi
UPDATE use --cached
to only check cached files.
Or without pretty-quick, replacing the line in Husky(other task runners are available)'s
./.husky/pre-commit
with...LIST=`git diff-index --name-only HEAD`; if [ "$LIST" ]; then npx prettier --write $LIST; git add $LIST; fi
It doesn't work, this solution adds to the commit all the changed files, and not only the staged ones.
It doesn't work, this solution adds to the commit all the changed files, and not only the staged ones.
Brutal! Updated with flag --cached
It doesn't work, this solution adds to the commit all the changed files, and not only the staged ones.
Brutal! Updated with flag
--cached
Now it works better, but if you're using the --staged
flag from pretty-quick
, it will not have the same behaviour
facing the same issue, moved to lint-staged for this reason
I replaced pretty-quick
(because it is incompatible with Prettier v3) with lefthook.
Here is a PR of mine that shows how to migrate to lefthook: https://github.com/bennycode/ts-node-starter/pull/601/files
I am working on a CLI tool to automatically configure projects. I decided to change pretty-quick in favor of lint-staged, precisely because lint-staged works perfectly without any problems.
If anyone wants to see the configuration files they can be found here: .husky/pre-commit .lintstagedrc package.json
I don't know why you haven't made it work, but I can offer some help or raise a PR for it.
Two options:
synckit
What do you prefer?
Just found #165
See https://github.com/prettier/pretty-quick/pull/165#issuecomment-1891463129
I'll take over @azz's place and help to maintain this package in few days. 🍻
I am working on a CLI tool to automatically configure projects. I decided to change pretty-quick in favor of lint-staged, precisely because lint-staged works perfectly without any problems.
Another option would be using "lefthook": https://typescript.tv/hands-on/typeerror-prettierresolveconfigsync-is-not-a-function/#replacing-pretty-quick-with-lefthook
moved to lint-staged just because of this issue
I have to reset the related PR #165 because it is full of bugs actually...
I'll rewrite the whole package with TypeScript.
I've just finished my promise.
pretty-quick
v4 has just been released with prettier
v3 support! Thanks @SukkaW for helping as always! ❤️
Should prettier/prettier#15337 be reverted and pretty-quick
be added back to the docs of pre-commit solutions?
Not an issue right now, but pretty-quick will break with v3 due to the removal of resolveConfig.sync (https://github.com/prettier/prettier/pull/12788).