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

Unable to add a space before function parens #494

Closed SeanGroff closed 4 years ago

SeanGroff commented 5 years ago

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

CiGit commented 5 years ago

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

SeanGroff commented 5 years ago

@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?

CiGit commented 5 years ago

I will suppose you enabled eslintInegration.

Would need some debugging.

connorlufei commented 5 years ago

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

lilililee commented 4 years ago

same problem +1

DaanGeurts commented 4 years ago

Same problem here +1

paulsmithkc commented 4 years ago

Same problem +1

felipebalbi commented 4 years ago

same here

maxmannen commented 4 years ago

Same here

flm8620 commented 4 years ago

+1

kamaladenalhomsi commented 4 years ago

+1

SevenElement commented 4 years ago

+1

jcperez-ch commented 4 years ago

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.

paulsmithkc commented 4 years ago

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.

jaonoctus commented 4 years ago

same problem +1

acarlstein commented 4 years ago

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() {}. :(

moreant commented 4 years ago

Same here

kothanzaw commented 4 years ago

same +1

TiagoHA commented 4 years ago

same problem +1

davideprevosto commented 4 years ago

The same is happening to me

TheDoctor96 commented 4 years ago

same

gustavocardoso commented 4 years ago

Same here!

kamaladenalhomsi commented 4 years ago

same +1

Vorelli commented 4 years ago

^^

yuvachang commented 4 years ago

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

Vorelli commented 4 years ago

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

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

rebeccapeltz commented 4 years ago

same problem

thanhdevapp commented 4 years ago

same problem + 1

igortullio commented 4 years ago

Same here

ilan274 commented 4 years ago

Same issue here.

zindont commented 4 years ago

Same issue with vue :(

alexkhimich commented 4 years ago

+1

pwasem commented 4 years ago

+1

unickq commented 4 years ago

+1

ntotten commented 4 years ago

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