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

Control block formatting #98

Open
ghost opened this issue Apr 28, 2017 · 1 comment
Open

Control block formatting #98

ghost opened this issue Apr 28, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 28, 2017

I would like to know if the following can be accomplished with the typescript-formatter options that are currently available.

Take this control block here:

if (true) {
    // do something
} else {
    // do something else
}

Using my settings (see below) the formatter converts it to

if (true)
{
    // do something
} else
{
    // do something else
}

Is there a way to format it so that the "else" is in a new line? It should look like this:

if (true)
{
    // do something
}
else
{
    // do something else
}

What would be the best way to define such a rule? Insert a newline after the closing brace, or insert a newline before the "else"?

Here are my options for typescript-formatter

{
    "insertSpaceAfterCommaDelimiter": true,
    "insertSpaceAfterSemicolonInForStatements": true,
    "insertSpaceBeforeAndAfterBinaryOperators": true,
    "insertSpaceAfterConstructor": false,
    "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
    "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, // ()
    "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, // []
    "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true, // {}
    //   "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
    //   "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
    //   "insertSpaceAfterTypeAssertion": false,
    //   "insertSpaceBeforeFunctionParenthesis": false,
    "placeOpenBraceOnNewLineForFunctions": true,
    "placeOpenBraceOnNewLineForControlBlocks": true
}
@vvakame
Copy link
Owner

vvakame commented May 3, 2017

sorry, I have no idea.
Is it can on VSCode or any other editor that uses TypeScript LanguageService?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant