When I saved a javascript file today, I noticed that it deleted the parentheses around a sole arrow function parameter: (res) => {} turned to res => {}, which was not what I wanted.
Then I set "prettier.arrowParens" to "always" in settings.json, it still showed that way.
If you have a prettier config file, those settings dismissed, thus prettier will format with settings given in one of those files or default.
https://prettier.io/docs/en/configuration.html
Are you using .vue files with Vetur extension? If so I had the same issue and just opened a PR https://github.com/vuejs/vetur/pull/727 to fix it.
@forsartis I edited those two .ts files but it still didn't work. Is there anything more that I should do ?
@CiGit Thanks! Maybe it was caused by Vetur I think.
Just changing those files won't work (needs to be recompiled from source). We have to wait for the Vetur extension to get updated.
For a hotfix you can try adding this to your package.json file:
"prettier": {
"arrowParens": "always"
}
@forsartis Got it. Thank u very much!
Seems to be an issue with Vetur, not with vscode. closing
@CiGit This worked for me: https://alligator.io/vuejs/eslint-vue-vetur/
In my case is not working on User Settings neither Workspace Setting. Is working with no problems using Prettier configuration file or in the Package.json file. Should I open anther issue @CiGit?
Update: Seems to work on a fresh installation. So, should be a conflict with an extension. No longer to create another issue.
Just for information, setting "prettier.tslintIntegration": true, causes that the arrow rule does not comply User or Workspace settings.
Hey @CiGit I'm having problems with arrowParens in vs-code. For some reason, it always turns my arrow functions into ones without the parens.
My code
class Queue {
constructor() {
this.inbox = new Stack();
this.outbox = new Stack();
}
// called to add an item to the `queue`
enqueue(...args) {
args.forEach((item) => console.log(item));
args.forEach((item) => {
this.inbox.push(item);
});
}
}
always turns into
class Queue {
constructor() {
this.inbox = new Stack();
this.outbox = new Stack();
}
// called to add an item to the `queue`
enqueue(...args) {
args.forEach(item => console.log(item));
args.forEach(item => {
this.inbox.push(item);
});
}
}
here is my prettierrc.json
{
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"arrowParens:": "always"
}
vscode config
{
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.shell.osx": "/bin/zsh",
"editor.formatOnSave": true,
"prettier.singleQuote": true,
"editor.tabSize": 2,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
I know this is a problem with the extension itself because it works in the prettier playground
https://prettier.io/playground/#N4Igxg9gdgLgprEAucAbAhgZ0wAgIoCucROwAOlDjpFJjAE4FgwT0AUAlKRVVTABYBLTADpBUAEYQAHjgC8OKHADuOAMox0YANacA3D14DhIiARhTZCpao1bdHA5RwBfCoYD0H6ulSo4ACY4LDjoAUHolILwALbBEMH8cDgABgCOREQphggZxHBsIkXo9ADmmFzkzlQl5SIAZqwAolr8bNFwcXIAfNTQmBD+IqgQpe2xHI6GNWWijfQtYG0dXb1VvEZCouKWIgAOBJjLE04bLlPOblCe3gFweUSc3M5evIL1OGzGomYWMiKYQQALwKXDk4JwAAZKjcNjhlEJ-J8dv9ASCngBCCHQ55UV5wnC-XYHI7tST-PYQPacC547xnWFUK503j0OAwAj0ShEilU-Swq6wtGg3E4fE4Nkcrk4FHSAHAkUAakJ5l2wv5L28gs1OD2cDgDlF4slnO5qv+SmkMCeAB8bTLyXLLdbaWKte4dSMxjCdVQaAMhl62IzeAByB5wJA4UMAGhDVFl8d4AM0Ok4SaoIjZADc4PRMKCMzgRDQwOhrTy5XR7DSiyIYuhqWB5L0wCIoOgYnAOCHXa8rtqYhAAgQhnBpJT6DBcApCPk9CAYyAqTBBP1kKASvQIMoAAolBCYZAgXzKdAATyPS4k9Hs7LUey04lKyAYRCX-BgMVQAHUhPBMEfMA4DUQ9okEbNonPY8wGwRcQHEAsp13W9SgbZB6l8AslwAK0waQACFbx0e9OzgAAZcQ4AwrC4Fw-C1GffxCAgeAaNQbCQEffM82PCR0Akc8RigeC9nocQYB-QQAgEZAAA5ISXMSIALH9bz2Y8xLgJDc3gjJWLgFCqSPFAsAAWiUQJAngtkMkENkUPQND0HYziCxiQRX0YOiQEBKBSmYggDNcnzNAkKSZP4ZAACYlwYdBBFQZ8AGEIBidCUCgaBqKXQ44AAFQEkzMI4uAXBcIA
Also tried to add this to my workspace vs-code settings and it didn't work either
"prettier.arrowParens": "always",
Also tried to add this to my workspace vs-code settings and it didn't work either
"prettier.arrowParens": "always",
Use it like this:
{
"vetur.format.defaultFormatterOptions": {
"prettier": {
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
}
},
"prettier.semi": true,
"prettier.singleQuote": true,
"prettier.trailingComma": "es5",
"prettier.arrowParens": "always"
}
.prettierrc
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"printWidth": 100,
"singleAttributePerLine": true,
"bracketSpacing": true,
"arrowParens": "always"
}

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.
Most helpful comment
Just changing those files won't work (needs to be recompiled from source). We have to wait for the Vetur extension to get updated.
For a hotfix you can try adding this to your
package.jsonfile:"prettier": { "arrowParens": "always" }