Skip to content

Don't put the body expression of an arrow function on a new line and indentation level without also enclosing it within parentheses #748

@pineapplemachine

Description

@pineapplemachine

Currently I have code like this. This instance is written as an item in a function's multi-line argument list, hence the trailing comma:

(args...) => myFunction({
    prop1: etc,
    prop2: etc,
    prop3: etc,
}),

As above is my preferred way of formatting this code, but I would also accept one of these:

(args...) => (myFunction({
    prop1: etc,
    prop2: etc,
    prop3: etc,
})),

(args...) => (
    myFunction({
        prop1: etc,
        prop2: etc,
        prop3: etc,
    })
),

However, dprint is formatting this code like so, with my current settings:

(args...) => 
    myFunction({
        prop1: etc,
        prop2: etc,
        prop3: etc,
    }),

I think that arbitrary indented blocks without enclosing parens/brackets/braces harms code readability and should always be avoided. But I haven't found an option that I can use to change this behavior.

Might be related to #746

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions