-
-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting issues #476
Comments
I cannot get Vetur to read from Here's the object being exported in my config file:
The configuration works as expected except in Vue files. Is there anything else I'm missing? |
We don't read from Change your workspace setting (or directly edit {
"prettier.singleQuote": true,
"prettier.trailingComma": "es5"
} |
In The end of the line does not keep the semicolon, how to set it? @octref |
Ok, when i installed prettier plugin for my vscode, I could see all the configurable items. |
javascript formatter seems broken after update to vscode 1.17.2 |
@maple3142 Edit: In .vscode/settings.json I added three new configuration items: {
"prettier.singleQuote": true,
"prettier.semi":false,
"vetur.format.defaultFormatter.html": "js-beautify-html"
} |
@maple3142 Can you provide more info on what's not working? If you don't like prettier, you can always set |
@octref Not that I'm maple3142, but I too have experienced the bug I believe they are referencing; to expand: when saving a file with a wrongly indented method in an object, the incorrect indents remain, and nothing is changed. I could try to provide a gif, but my methods for generating them aren't very easy at this moment. And yes, I tried the vscode-typescript setting you mentioned above; no change. Example of incorrectly indented method: export default {
methods: {
one() {
}
}
} |
|
@octref It is already set to true. |
@Daedalus11069 Any errors on Panel -> Output -> Vue Language Server? OS / VS Code / Vetur versions? It's working for me. |
@octref The error messages are as follows, repeating indefinitely; apologies for not including this sooner:
Edit: Not that it matters anymore.. restarted and it's working now. Still, not deleting this post in case it helps to pinpoint the problem... if there is one. |
js formatter seems not to read .eslintrc rules.
parameter |
when I am trying to set vetur.format.defaultFormatter.js: "vscode-typescript", I got below error: Value is not accepted. Valid values: ["none","js-beautify-html"] |
For me too formatting isn't working anymore after the the update to the latest VSCode. It seems like .eslintrc.js is ignored. |
For those looking for a quick fix for vue files with
|
@octref thanks, it works as before after I set |
@octref thanks, it can work after I set
|
How to integrate with |
Until recently, Vetur formatting worked out of the box with Vue. Somehow Vetur got broken after the most recent VSCode update (1.17.2). With broken I mean that my Vue project (generated using vue-cli) with ESLint standard config was not adhered. So formatting .vue files would result in:
This basically means that anyone starting a Vue project using vue-cli with the (default) standard config will have broken formatting when using VSCode and Vetur. After some plenty research, I ended up adding the following the configuration parameters to my VSCode settings to fix these issues:
This will make everything work as it used to. I don't really understand why the default settings are broken or why I have do this at all, but in any case, this fixed my issues. I'm not sure where the problem exactly lies. Do we need to update the documentation to explain the necessary steps to make sure Vetur works, or is it perhaps more wise to make sure the default configuration works? |
@mcrapts thanks so much! I had the exact same thing and this solved it. Had no idea why everything suddenly broke... Maybe Vetur can get some better testing here? vue-cli webpack template is the base for a lot of projects, I'd expect it to work perfectly there. |
but ctrl+space code suggestion not working? |
js-beautify was removed because it was causing issues for people and upstream bugs never get fixed. Changing to prettier was my own opinion. You are still given the option to use the old formatter. I'll update veturpack after I implement prettier-eslint so the formatting can be consistent. @johncloud200 Open an issue with repro case. |
@octref I understand your reasoning, but is this alternative better? Because now it doesn't work at all without additional configuration. |
When prettier-eslint support is added it'll work out of the box, since eslint has autofix for space before paren. This way .eslintrc becomes a single source of truth for your code format (errors + formatter). TS formatter on the other hand don't care about ESLint. |
Alright, seems like the way to go then. Until then I'll use the above configuration :). |
Note that All added settings below: "vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatter.html": "js-beautify-html",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true, |
Like already said, it'd be cool if Vetur could read the prettier configuration instead of having to set it in worspace settings configuration for teams that use several editors. |
Is is possible for vetur to read .eslintrc? I have setup airbnb code rules and I do not want to change them. But since last update everything is broken. It is forcing me to use prettier which I do not want. 😞 |
ESLint integration is in #478. Will release soon. |
Thanks @octref - looking forward to this release. |
This still doesn't work in vetur 0.11.5, vscode 1.19.1:
eslint 4.15 installed globally /home/user/work/dashboard/.eslintrc.js
When saving a .vue file, semicolons are added automatically (instead of being removed) |
@mariusa |
Thanks, that does work. But above @octref says
So, why is vscode settings "prettier.semi" still needed? |
@mariusa If you have ESLint autofix for |
vscode 1.19.2 vetur 0.11.6, cannot get
|
Vetur's version of prettier does not respect my ESLint rules even though I have |
This might be related to prettier/prettier-eslint#94. I have set up a PR prettier/prettier-eslint#165. Waiting for prettier-eslint maintainer to approve and then we can propagate it to editor plugin makers |
Follow doc https://vuejs.github.io/vetur/linting-error.html or the setup at https://github.com/octref/veturpack Please do not use |
I am fairly certainly this is a bug with the vue-language-server. In https://github.com/vuejs/vetur/blob/master/server/src/utils/prettier/index.ts#L42, the only thing passed into prettier-eslint is just the text and some prettier fallback options. options.filename is not passed in. .eslintrc has to been resolve from file location. Thus in the absence of filename, eslint --fix will be called with an empty option hence nothing will be changed after prettier step. |
Please reopen this issue. A one-liner fix |
@yongjun21 It's more involved than you thought. Passing in |
@dmzkrsk I have updated the vetur to 0.12.3, and this problem still existed... |
I still have a formatting issue with Vetur, it's pretty annoying. I am pretty sure my eslintrc is fine but for some reason, Vetur prefers to use prettier and failed on reading my eslintrc. I sincerely suggest Vetur to use |
I had |
Can someone confirm that Vetur is not reading .eslintrc.js file for prettier formatting? |
Also needing the following configuration:
|
the line "vetur.format.defaultFormatter.html": "js-beautify-html", is not needed. |
scriptDoc.languageId
seems to always bejavascript
even iflang="ts"
. This causes the defaultFormatter used for js to be used for ts.Don't know if people would want to have a separate prettier setting than their global one, so maybe add prettier to
defaultFormatterOptions
.Might be good to add
stylus-supremacy
todefaultFormatterOptions
too for some more sane defaults.Does not work well with multiple workspace now because of settings. Will take a look later.
The text was updated successfully, but these errors were encountered: