Yikes2000 / prettier-plugin-merge-extras

A Prettier plugin to offer more options.
MIT License
12 stars 0 forks source link

Using preserveDotChain creates unnecessary whitespace in TypeScript #3

Open Kaysen98 opened 6 days ago

Kaysen98 commented 6 days ago

Dependency information

"prettier": "3.3.2" "@yikes2000/prettier-plugin-merge-extras": "^0.7.1-extras.3"

Steps to reproduce

The problem seems to happen, if you have a file that contains tabs and the prettier config is set to "useTabs": false. When the tabs are removed and the indentation is reduced it seems to not remove the whitespace between the keyword "await" and "transaction".

If "useTabs": true" is used and the indentation is not changed the problem does not occur. If I remove the "await" keyword, the problem does not occur as well.

This is before, but every function is already in a newline, but I couldnt format it here accordingly.

await transaction.request().input(...).query(...);

Turns to:

await transaction

The formatter correctly puts each dot chained function in a newline as expected, but also adds this whitespace between "await" and "transaction".

Thanks in advance!

Yikes2000 commented 4 days ago

Unable to duplicate. . .

preserveDotChain: true,
tabWidth: 4,
useTabs: false,

Input:

async function foo() {
<tab>await transaction
<tab><tab>.request()
<tab><tab>.input("foo bar")
<tab><tab>.query("bat moo");
}

Output:

async function foo() {
<4 sp>await transaction
<8 spaces>.request()
<8 spaces>.input("foo bar")
<8 spaces>.query("bat moo");
}

<4 sp> = 4 spaces
<8 spaces> = 8 spaces

Please provide 'input' code that illustrate the bug?