prettier / prettier-vscode

Visual Studio Code extension for Prettier

Home Page:https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to add a space before function parens

SeanGroff opened this issue · comments

Default behavior for ESLint is to add a space before function parens. This is also a defined rule with StandardJS.

eslint space-before-function-paren

Currently, if you use the Prettier VS Code extension and enable "editor.formatOnSave": true in your settings.json the space between the function name and parens is removed on save. There is no way to control this behavior in Prettier.

space-parens

Does it work as expected if you call Format document instead of relying on formatOnSave?

@CiGit I forgot to mention I tried this as well and it does not make a difference. Any other information that might be helpful to include on this issue?

I will suppose you enabled eslintInegration.

Would need some debugging.

commented

I got the same problem here, it just remove the space before function parens no matter how you config the eslintrc.js

same problem +1

Same problem here +1

Same problem +1

same here

Same here

commented

+1

I guess it's one of those cases where a linting rule conflicts with a prettier rule. Unfortunately in prettier there is no way we can sync the desired behaviour described on a lint configuration.
The only way I see I can stop focusing about linting and keep focus on code is to disable this lint rule in favour of what prettier offers. I really would like to see more integration between prettier and linters, specially for pretty code rules.

This isn't a problem with linting as much as it is a case of overreach and lack of configurability. The whole point of the original post is that it is turning an export into a function call, which changes the execution of that line of code.

same problem +1

Even when I add spaceBeforeFunctionParen as true in the .prettierrc file, when running Format Document in a vue file, the space between the keyword function and the parenthesis is removed. So from data () {} (which is what I need so ESLint doesn't complain) it turn into data() {}. :(

Same here

same +1

same problem +1

The same is happening to me

same

Same here!

same +1

I'm having this issue too. Any resolution yet?

I'm having this issue too. Any resolution yet?

I just went and disabled the rule in my eslint config.

same problem

same problem + 1

Same here

Same issue here.

commented

Same issue with vue :(

So this is really just a difference of opinion of the formatter and linter. The only solution is to match eslint with what prettier allows. The recommendation is to disable formatting rules in eslint and just let prettier handle this: https://prettier.io/docs/en/integrating-with-linters.html#disable-formatting-rules

If you would like a setting in prettier for this, you will need to open an issue in the core repo to suggest that option: http://github.com/prettier/prettier