Open jgwinner opened 3 years ago
It's because of "yarn prettier" executable. Multilinter searches for a "yarn prettier" executable up to the root. Of course it cannot find such file (which name should be "yarn prettier.exe/cmd/bat" and so it fails. Actually is only supported to launch those externals executable directly, such as prettier.exe/cmd/etc, not by using yarn. Sorry.
Prettier isn't a .exe, it's JS, so it has to be run via Node, i.e. npm or yarn. There is a .CMD though, which includes that, so I'm getting closer with this, but {filename}
isn't expanding.
That's got to be a bug.
{
"prettier": {
"enabled": true,
"additionalArguments": --write "\"{filePath}\" ",
"fileExtensions": "js,vue",
"executable": "prettier.cmd",
"StdInArguments": ""
}
}
gives me this error:
Formatters found to be used for file extension ".vue" found: prettier,
About to format by:
Formatter: "prettier"
Current Directory: "C:\c\stuff\"
Command line: "C:\c\stuff\node_modules\.bin\prettier.cmd"
Arguments: ""{filePath}" --write"
Error:
[error] No files matching the pattern were found: "{filePath}".
If I include {filename}
in the StdInArguments it works fine, but replaces my file with the timing of the results. No other combination of {filename}
or \"{filename}\"
ever worked. It works fine from the command line.
So, I tried:
"prettier": {
"enabled": true,
"additionalArguments": "--parser vue",
"fileExtensions": "js,vue",
"executable": "prettier.cmd",
"StdInArguments": "\"{filePath}\""
}
}
This locks up visual studio. Had to kill it with the task manager.
Third (tieth) try is the charm, this works:
{
"prettier": {
"enabled": true,
"additionalArguments": "",
"fileExtensions": "js,vue",
"executable": "prettier.cmd",
"StdInArguments": "--parser vue"
}
}
Because I am using the 'standard' Prettier with an off the shelf install, I think the above settings should be the default in .MultiLiter, or at least documented.
So, it's now working!
Whoops - it broke Javascript
So is it working now? Also, because the base config for prettier is:
{ "prettier": { "enabled": false, "additionalArguments": "", "fileExtensions": "", "executable": "prettier.cmd", "arguments": "--write \"{filePath}\"", "stdInArguments": "--stdin-filepath \"{filePath}\"", "installationType": "local", "toolType": "formatter" } }
When you want to add a stdInArgument you should add the string to the string in the base config. So you should write:
{ "prettier": { "enabled": true, "additionalArguments": "", "fileExtensions": "js,vue", "executable": "prettier.cmd", "stdInArguments": "--stdin-filepath \"{filePath}\" --parser vue" } }
But I think you can also use:
{ "prettier": { "enabled": true, "additionalArguments": "--parser vue", "fileExtensions": "js,vue" } }
Let me know.
Ok, I'll try those, thanks.
The only problem with "--parser vue" was that it broke Javascript, so I could use a different linter that's supposed to do prettier with .js, as the original problem was that one didn't do .vue files. Your add-in does, and it's about the only one. What was weird, is that prettier didn't seem to do .vue files unless I added the --parser vue.
I'll fiddle with it some more. At least now, between the standard linter and your adding, I can get Nuxt to compile and run! Our project upgraded from a 1.x of Prettier to a 2.3.X, which broke a bunch of stuff.
Hi
I downloaded the extension, install it, configured it in VStudio to run on save:
then setup the
.multilinterrc.json
file as in your example:Works great.
I then try prettier, by changing the
.multilinterrc.json
but it never runs:Odd. My package.json has:
Note that per the docs at: https://prettier.io/docs/en/install.html the command is yarn prettier, so I modified your setup:
Now it thinks prettier is configured, BUT still won't run. Debug output:
eslint works fine.
Any ideas? I'm sure it's some other parameter is different from the seeded setup files and our setup, which I thought was fairly off the shelf. Prettier is mandated by the org.