question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to add a space before function parens

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:29
  • Comments:35 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
acarlsteincommented, Jan 16, 2020

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

2reactions
paulsmithkccommented, Jan 16, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code - space before function parentheses - Stack Overflow
In VS Code open File -> Preferences -> Settings; Add to your JSON config: "javascript.format.insertSpaceBeforeFunctionParenthesis": true.
Read more >
space-before-function-paren - Pluggable JavaScript Linter
This rule aims to enforce consistent spacing before function parentheses and as such, will warn whenever whitespace doesn't match the preferences specified.
Read more >
Prettier Function Parenthesis Spacing - Opinionated is Key
Upon running Prettier, I noticed that it kept adding spaces between the function keyword and the argument parenthesis. For example (demo):.
Read more >
C++ Formatting's Spacing for Function Parentheses would ...
This highlights a vague, obscure bug in the C++ document parser that is attempting to format C++ documents. In reality, typedef function pointer...
Read more >
Prettier-space-parenthesis - npm.io
I know but code without spaces looks ugly for me. Why adding a space before a if () , while () and not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found