dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

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

Open pineapplemachine opened this issue 3 months ago • 0 comments

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

pineapplemachine avatar Oct 31 '25 17:10 pineapplemachine