prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.04k stars 446 forks source link

Prettier 3 - Invalid host defined options #3114

Closed leppaott closed 8 months ago

leppaott commented 9 months ago

Hello, we just updated Prettier to latest version 3 as well as typescript, jest and ts-jest.

After which formatting on test files stopped:

"INFO" - 2:54:03 PM] Formatting file:///home/file...test.ts
["ERROR" - 2:54:03 PM] Error resolving prettier configuration for /home/file....test.ts
["ERROR" - 2:54:03 PM] Invalid host defined options
TypeError: Invalid host defined options
    at Object.<anonymous> (/home/...node_modules/prettier/index.cjs:600:23)
    at u._compile (/usr/share/code/resources/app/out/vs/loader.js:4:1271)
    at Module._extensions..js (node:internal/modules/cjs/loader:1243:10)
    at Module.load (node:internal/modules/cjs/loader:1058:32)
    at Module._load (node:internal/modules/cjs/loader:893:12)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:130:28084)
    at f._load (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:130:25418)
    at C._load (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:94:19511)
    at Module.require (node:internal/modules/cjs/loader:1082:19)
    at g (/usr/share/code/resources/app/out/vs/loader.js:4:647)
    at t.loadNodeModule (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:2829)
    at t.PrettierMainThreadInstance.import (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:17760)
    at t.ModuleResolver.getPrettierInstance (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:5728)
    at t.ModuleResolver.getResolvedConfig (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:7496)
    at t.default.format (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:14589)
    at t.PrettierEditProvider.provideEdits (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:12683)
    at t.PrettierEditProvider.provideDocumentFormattingEdits (/home/.../.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:8922)
    at U.provideDocumentFormattingEdits (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:44961)
    at /usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:67895
    at le.s (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:62744)
    at le.$provideDocumentFormattingEdits (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:67882)
    at t.N (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:7983)
    at t.M (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:7749)
    at t.H (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:6791)
    at t.G (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:5906)
    at r.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:4736)
    at f.w (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:1902)
    at f.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:2119)
    at y.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:79:13931)
    at r.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:130:30355)
    at f.w (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:1902)
    at f.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:2119)
    at y.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:79:13931)
    at MessagePortMain.<anonymous> (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:130:28635)
    at MessagePortMain.emit (node:events:513:28)
    at MessagePortMain.emit (node:domain:489:12)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)

Also code files formatting doesn't work but sometimes it does. Does this extension use tsconfig or such?

Prettier config is on path services/.prettierrc and test files are on services/module/__tests__/e2e/name.test.ts and code on services/module/src/...

leppaott commented 9 months ago

[10.1.0] Reverts back to prettier 2.x by default due to issues with extension

[10.0.0] Use Prettier 3.0 by default. Change default configuration for trailingComma to all to match Prettier 3.0.

OK seems it could be by these changes? Prettier 2 works!

thj-dk commented 9 months ago

Can confirm this error.

talmosko commented 9 months ago

same here

Connorelsea commented 9 months ago

Seeing this same issue in latest plugin version. Downgrading to prettier 2 fixed it.

mrfy commented 9 months ago

same here

schwarzsky commented 9 months ago

Can confirm the issue

lenaggar commented 9 months ago

yup, same!

MaximMaximS commented 9 months ago

Removing prettierPath from vscode settings fixed it for me (from https://github.com/n8n-io/n8n/pull/6952).

EDIT: No it didn't, now the extension ignores my config.

thisislvca commented 9 months ago

Removing prettierPath from vscode settings fixed it for me (from n8n-io/n8n#6952).

This worked for me too! Thanks for the suggestion. Hopefully this gets fixed asap...

MaximMaximS commented 9 months ago

Removing prettierPath from vscode settings fixed it for me (from n8n-io/n8n#6952).

Well I've missed that the extension now ignores my config, so its not really a fix :(

christiango commented 9 months ago

Have you all tried the workaround in #3100? That resolved this for me

danieljonsson90 commented 8 months ago

Have you all tried the workaround in #3100? That resolved this for me This was the only fix that worked for me

en3sis commented 8 months ago

After updating to 3.0, my project was throwing the same error. What fixed it for me was disabling/enabling the Prettier extensions in VSC.

manchicken commented 8 months ago

Removing the prettierPath in the config did help me. Don't know whether it's reading the config (it seems weird that it wouldn't), but I did change it and then it did start working.

angusryer commented 8 months ago

Removing prettierPath config field from .prettierrc worked for me. I have prettier 3.0.3 installed locally in my project.

MaximMaximS commented 8 months ago

Removing prettierPath from vscode settings fixed it for me (from n8n-io/n8n#6952).

Well I've missed that the extension now ignores my config, so its not really a fix :(

Well, now it seems like it reads my config again, so the issue seems to be gone.

leppaott commented 8 months ago

We haven't used prettierPath but extension settings: "prettier.configPath": "services/.prettierrc", and we still got this.

leppaott commented 8 months ago

Yeah I removed configPath from settings.json commited to repo and now the plugin formatting seems to work and also apply the prettierrc config.

leppaott commented 8 months ago

Right this was only an issue with the path ./services/.prettierrc works for me while before services/... would work without ./

getellez commented 7 months ago

Restarting the vscode and removing the prettierPath form the vscode settings worked for me

trusktr commented 7 months ago

I restart VS Code, the problem goes away for a while, then comes back after some time, then I restart VS Code again each time it happens and I'm good for a while.

Something is up with it.

@leppaott can you please re-open this (but unsubscribe if you need)?

mr-moon commented 6 months ago

Still issue, .prettierrc is in root dir.

whosesmile commented 4 months ago

When I updated the prettier version in my project to 3.x.x, the formatting functionality didn't work, but when I updated the latest prettier plugin(vscode plugin), it worked fine.

kee-oth commented 4 months ago

I'm getting this error with Prettier 3.2.2 and Prettier VSCode Extension 10.1.0. This is in a brand new project that uses a .prettierrc in the root. In VSCode, I've tried specifying and not specifying where my .prettierrc file is, with both absolute and relative paths.

samuk10 commented 3 months ago

somehow my prettier just accepted the .yaml format! .prettierrc.yaml https://prettier.io/docs/en/configuration.html

github-actions[bot] commented 2 weeks ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.