Skip to content

[JavaScript] Questionable indentation when formatting Method Chaining with Block Lambda Argument #26

Description

@scscgit

Plugin currently Formats Code with a Block Lambda Argument like this:

[].filter(b=>true)
    .forEach(() => {
    console.log("test");
});

As you can see, the function body is on the same level as the method chaining, so the code isn't readable at all.

I believe this to be the correct indentation:

[].filter(b=>true)
    .forEach(() => {
        console.log("test");
    });

📓 Side note: also when adding a comment above any chained method, it always starts without indentation, even if it's indented all around it.

[].filter(b=>true)
// Comment above a chained method should be indented
    .forEach(() => {
        console.log("test");
    });

Method chaining per line is very popular for good code readability, so I hope it's within the scope of this plugin's formatter 🙂

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions