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.

disabled space-before-function-paren adds a space between generic and function paren

See original GitHub issue

Edited, initial version was not correct

I came across the weird and likely wrong behavior with formatting of the next lines of code

function foo<T>(x: T): T {
  return x
}

Even if I don’t pass --space-before-function-paren flag (default value is false), space is added between foo<T extends number> and (x: T),

so the result is:

function foo<T> (x: T): T { // <-- space between <T> and (x: T)
  return T
}

Could you please confirm it’s an issue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
brodybitscommented, Nov 24, 2019

Thanks @havenchyk, I added the bug label with help wanted for now. A new test case would be very helpful.

0reactions
havenchykcommented, Nov 23, 2019

@brodybits new info came.

import prettierx from 'prettierx'

const options = {
  spaceBeforeFunctionParen: false,
  generatorStarSpacing: true,
  yieldStarSpacing: true,
  singleQuote: true,
  semi: false,
  jsxSingleQuote: true,
  useTabs: true,
  endOfLine: 'lf',
  filepath: '/Users/havenchyk/projects/test-prettierx/index.ts',
  parser: 'typescript'
}

const text = 'const foo = function<T>(bar: T) { return bar }'

const formatted = prettierx.format(text, options)

console.log(formatted)

/**
 * const foo = function<T> (bar: T) {
 *   return bar
 * }
 */

Tried it with version 0.10. Am I doing formatting wrong? I’m also surprised it’s different from the result from CLI

Read more comments on GitHub >

github_iconTop Results From Across the Web

space-before-function-paren - TypeScript ESLint
This rule extends the base eslint/space-before-function-paren rule. It adds support for generic type parameters on function calls.
Read more >
Space after function keyword - MOVED to #3847! · Issue #1139
Current instruction: Disable the space-before-function-paren ESLint rule. If Prettier adds support for printing that space: Use ...
Read more >
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 - GitLab
This rule extends the base eslint/space-before-function-paren rule. It adds support for generic type parameters on function calls.
Read more >
Enforces consistent spacing before function parenthesis ...
This rule extends the base eslint/space-before-function-paren rule. It adds support for generic type parameters on function calls.
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