Skip to content
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

space-before-function-paren #12234

Closed
waderyan opened this issue Nov 14, 2016 · 9 comments
Closed

space-before-function-paren #12234

waderyan opened this issue Nov 14, 2016 · 9 comments
Assignees
Labels
Domain: Formatter The issue relates to the built-in formatter Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@waderyan
Copy link

From @aochsner on November 11, 2016 22:19

We use space-before-function-paren in our eslint rules for readability. I'd like an option to format to this behavior

  • VSCode Version: 1.7.1
  • OS Version: macOS Sierra 10.12.1

Steps to Reproduce:

  1. Type function foo () { }
  2. Format the code (if it doesn't auto-format)
  3. Code is formatted to function foo() { } with no mechanism to override

Copied from original issue: microsoft/vscode#15386

@waderyan waderyan self-assigned this Nov 14, 2016
@waderyan
Copy link
Author

@aochsner thank you for opening this issue. The functionality for formatting is provided by TS Server. I will migrate this feature request to their repo.

@waderyan waderyan added VS Code Tracked There is a VS Code equivalent to this issue Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature and removed feature-request labels Nov 18, 2016
@hxshandle
Copy link

Hi team, I met the same problem, this made me so sad, I have to format my code in command line tools since the build-in formatter will change function () -> function() .

@aochsner
Copy link

aochsner commented Dec 9, 2016

So I have gotten around this issue a little bit by turning on:
"eslint.autoFixOnSave": true

in my settings.

@waderyan waderyan changed the title Javascript formatter: space-before-function-paren space-before-function-paren Dec 10, 2016
@hxshandle
Copy link

@aochsner yeah, you approach works fine for me, thanks.

@mhegazy mhegazy added Suggestion An idea for TypeScript Domain: Formatter The issue relates to the built-in formatter Help Wanted You can do this and removed Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Dec 15, 2016
@mhegazy mhegazy added this to the Community milestone Dec 15, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Dec 15, 2016

PRs welcomed.

@aochsner
Copy link

Happy to take a stab... can you point me in the right direction?

@DanielRosenwasser
Copy link
Member

The formatting logic resides in src/services/formatting. You'll want to check out the tests/cases/fourslash directory and peek around to get a sense of how to write a formatter test.

Also see our CONTRIBUTING.md.

aochsner pushed a commit to aochsner/TypeScript that referenced this issue Dec 20, 2016
Adding option InsertSpaceBeforeFunctionParenthesis
Should be optional
Typically used to support http://eslint.org/docs/rules/space-before-function-paren

Fixes microsoft#12234
aochsner pushed a commit to aochsner/TypeScript that referenced this issue Dec 20, 2016
@aochsner
Copy link

Okay. I added a couple more test cases for InsertSpaceBeforeFunctionParenthesis. Found InsertSpaceAfterFunctionKeywordForAnonymousFuctions to cover that case. Added InsertSpaceAfterConstructor to handle that case. That should cover the main cases that http://eslint.org/docs/rules/space-before-function-paren enforces.

Let me know what else should be done. Thanks!

@mhegazy mhegazy modified the milestones: TypeScript 2.2, Community Dec 21, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Dec 21, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Dec 21, 2016

thanks @aochsner!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Domain: Formatter The issue relates to the built-in formatter Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

5 participants