Lonefy / vscode-JS-CSS-HTML-formatter

JS,CSS,HTML formatter for vscode
48 stars 23 forks source link

Unwanted line break in javascript class private fields on save #141

Open Wombosvideo opened 2 years ago

Wombosvideo commented 2 years ago

Description

When creating private fields in javascript classes this formatter adds a newline between the # and the variable name. This results in invalid javascript code.

Example

The code

class MyClass {
    #myPrivateField = 'some value';
}

is turned into

class MyClass {
    #
    myPrivateField = 'some value';
}

on save. This is invalid javascript.

Further Information

To find out more about private fields in javascript classes, see section Private field declarations on mdn/JS/Classes.

Suggested Workaround

Since this extension is hardly maintained I suggest moving on from it and switching to an alternative like Prettier - Code formatter. Keep in mind that with every formatter the code looks a little different and you might have to change some settings in order for the code to look just the way you prefer.