millermedeiros / esformatter

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

Remove newline inMemberExpression #491

Open RoHePu opened 7 years ago

RoHePu commented 7 years ago

Hi esformatter team, after having some trouble with our current formatter, we would love to use esformatter for our web projects. The amount of options and settings are amazing.

But before we can use use esformat we have to fix some artefacts that our previous formatter produced. We would be lucky if we could fix it with an option or a lightweight plugin.

Because of a bug our current formatter produced code like this:

snoop
        .extend(
            "some id as string", 
    {});

We would love to have esformatter to format it to:

snoop.extend("some id as string", {});

The newline behind the string seems to be fixed by default settings. The newline before the string can be fixed by setting "lineBreak": {"Literal": 0}.

Now we are searching for a way to fix the line break between snoop and .extend. As far as I can see this node is a MemberExpression but I cannot find a way how to remove the linebreak within this expression.

Can you give me a hint whethter this is possible and if it is, how to write a plugin that fixes such kind of errors?

Thanks in advance :) Robin