Prettier-vscode: Can self-closing JSX end in last line instead of a new line?

Created on 1 Feb 2018  路  7Comments  路  Source: prettier/prettier-vscode

Input:
<View a={true} b={false} />

Actual Output:

<View 

        a={true} 

        b={false} 

/>

Expected Output

<View 

        a={true} 

        b={false} />

Is there an option to control this closing format?

locked need more info

Most helpful comment

jsxBracketSameLine is for opening bracket

jsxBracketSameLine === true

<Text
    style={...}>
    TEXT_HERE
</Text>

jsxBracketSameLine === false

<Text
    style={...}
    >
    TEXT_HERE
</Text>

All 7 comments

Hello @booker-laputa

I think you might need to give more information because I don't see the difference between

Actual Output:
<View a={true} b={false} />

Expected Output
<View a={true} b={false} />

@RobinMalfait , the editor auto formatted my code

I have updated

The "/>" is expected to be on the same line as "b={false}" but the actual output is "/>" always live in a new line

This is currently how prettier works, and I don't think that they are going to change it.
You can try to create an issue over there: https://github.com/prettier/prettier
Or
You can use an eslint plugin (https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) and enable eslint integration: prettier.eslintIntegration: true,

You might need to ask for that functionality in the eslint plugin.

Closing for now since we can't change the styling in this extension.

Isn't https://github.com/prettier/prettier-vscode#prettierjsxbracketsameline-default-false
the option you are looking for?

Hah, I didn't even know that existed, my bad!

jsxBracketSameLine is for opening bracket

jsxBracketSameLine === true

<Text
    style={...}>
    TEXT_HERE
</Text>

jsxBracketSameLine === false

<Text
    style={...}
    >
    TEXT_HERE
</Text>

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings