[llvm-bugs] [Bug 50501] New: JavaScript / TypeScript BreakBeforeBraces Problem

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 27 00:28:18 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50501

            Bug ID: 50501
           Summary: JavaScript / TypeScript BreakBeforeBraces Problem
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jkopecky at sievers-group.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

In JavaScript and TypeScript I fail to set the BreakBeforeBraces to always.
Moreover by function returns, the format differs according to the last comma
and semicolon. Some of that can be intentional, but I don't see any logic
there.

1) Is there a way to set BreakBeforeBraces to really always in JS and TS?
2) Is the function return behaviour intentional? (it should be actually solved
when 1) is solved

```
enum SampleEnum {
    ENUM1,
    ENUM2
}

const sampleObject = {
    sampleBoolean: true,
    sampleInt: 5
};

function noEndComma()
{
    return {first: true, last: false};
}

function noColon()
{
    return
    {
        first: true, last: false
    }
}

function endCommaAndColon()
{
    return {
        first: true,
        last: false,
    };
}
```

my setting:
```
---
Language:        JavaScript
BasedOnStyle:    Chromium
ColumnLimit:     100
BreakBeforeBraces: Allman

AlignConsecutiveAssignments: 'true'
AlignConsecutiveMacros: 'true'
AlignConsecutiveDeclarations: 'true'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLambdasOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeColon
AlwaysBreakTemplateDeclarations: Yes
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
DerivePointerAlignment: 'false'
IncludeBlocks: Preserve
IndentCaseLabels: 'false'
IndentWidth: '4'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: 'None'
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SortIncludes: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpacesInAngles: false
SpacesInContainerLiterals: false
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInParentheses: 'false'
TabWidth: '4'
UseTab: Never
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210527/30812efd/attachment.html>


More information about the llvm-bugs mailing list