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

Line breaks occur in strange places.

Open lazex opened this issue 2 years ago • 0 comments

Describe the bug

dprint-plugin-typescript version: 0.83.0

Input Code

a(() => {
    const b = c(d =>
        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    ).e;

    const f = (
        <>
            <Component
                callback={() => z()}
            />
            <Component
                callback={() => z()}
            />
        </>
    );
});

Expected Output

Same as input code.

Actual Output

a(() => {
    const b = c(d =>
        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    ).e;

    const f = (
        <>
            <Component
                callback={() =>
                    z()}
            />
            <Component
                callback={() => z()}
            />
        </>
    );
});

The arrow function in the first Component wraps, but second is not.

It does not occur in the following cases.

  • Change a(() => {}) to const a = () => {}.
    const a = () => {
        const b = c(d =>
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        ).e;
    
        const f = (
            <>
                <Component
                    callback={() => z()}
                />
                <Component
                    callback={() => z()}
                />
            </>
        );
    };
    
  • Remove variable b
    a(() => {
        const f = (
            <>
                <Component
                    callback={() => z()}
                />
                <Component
                    callback={() => z()}
                />
            </>
        );
    });
    
  • Remove .e property access
    a(() => {
        const b = c(d =>
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        );
    
        const f = (
            <>
                <Component
                    callback={() => z()}
                />
                <Component
                    callback={() => z()}
                />
            </>
        );
    });
    

lazex avatar Feb 15 '23 12:02 lazex