millermedeiros / esformatter

ECMAScript code beautifier/formatter
MIT License
970 stars 91 forks source link

Allman style in class definition #483

Open jfkairos opened 7 years ago

jfkairos commented 7 years ago

You can not set brace in next line after class declaration at column 0.

class A
{
    method()
    {
        return 1;
    }
}

.esformatter:

{
   "indent"      : {
        "value" : "····"
    },
    "lineBreak"   : {
        "value"  : "\n",
        "after"  : {
            "ClassClosingBrace" : 1,
            "ClassOpeningBrace" : 1
        },
        "before" : {
            "ClassClosingBrace" : 1,
            "ClassOpeningBrace" : 1
        }
    },
    "whiteSpace"  : {
        "value"  : "-",
        "after"  : {
            "ClassClosingBrace" : 0,
            "ClassOpeningBrace" : 0
        },
        "before" : {
            "ClassClosingBrace" : 0,
            "ClassOpeningBrace" : 0
        }
    }
}

Expected:

class-A
{
····method()-{
········return-1;
····}
}

Result:

class-A
····{
····method()-{
········return-1;
····}
}

I have used . and - for detecting if problem is indentation or whitespacing, so the opening brace is indented but whiteSpace is set to 0 and there is no indent.ClassOpeningBraceoption.

With functions i have not problems.