dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
Strange formatting with multi-line string interpolation
Describe the bug
The output of a multi-line string interpolation ends with the trailing brace zero-indented on a new line and the opening content indented the same as the ${.
I'd expect that either:
- The opening and closing braces hug the content (like the input code)
- Or the opening content is indented 1 step past the
${and that the closing brace either hug the content or be indented.
dprint-plugin-typescript version: 0.64.2
Input Code
const myList = [["x", "y"], ["a", "b"]];
const hi = `
${Object
.entries(myList)
.map(([firstKey, secondValue]) => `${firstKey}: ${secondValue}`)
.join(",\n")}
`;
Expected Output
const myList = [["x", "y"], ["a", "b"]];
const hi = `
${Object
.entries(myList)
.map(([firstKey, secondValue]) => `${firstKey}: ${secondValue}`)
.join(",\n")}
`;
or
const myList = [["x", "y"], ["a", "b"]];
const hi = `
${
Object
.entries(myList)
.map(([firstKey, secondValue]) => `${firstKey}: ${secondValue}`)
.join(",\n")
} // with some non-zero indentation here, no strong preference, but zero-indentation is is jarring.
`;
Actual Output
const myList = [["x", "y"], ["a", "b"]];
const hi = `
${
Object
.entries(myList)
.map(([firstKey, secondValue]) => `${firstKey}: ${secondValue}`)
.join(",\n")
}
`;
I'm not sure if this is a problem with my configuration, so I'm pasting it below:
{
"incremental": true,
"lineWidth": 100,
"useTabs": false,
"indentWidth": 2,
"typescript": {
"semiColons": "always",
"quoteStyle": "alwaysDouble",
"quoteProps": "asNeeded",
"newLineKind": "lf",
"useBraces": "always",
"trailingCommas": "onlyMultiLine",
"preferHanging": "false",
"arrowFunction.useParentheses": "force",
"spaceSurroundingProperties": "true",
"memberExpression.linePerExpression": "true",
"module.sortImportDeclarations": "maintain",
"module.sortExportDeclarations": "maintain"
},
"json": {},
"markdown": {},
"includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,md,mdx}"],
"excludes": [
"**/node_modules",
"**/storybook-static",
"**/yarn.lock",
"**/__generated__"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.64.2.wasm",
"https://plugins.dprint.dev/json-0.14.1.wasm",
"https://plugins.dprint.dev/markdown-0.12.2.wasm"
]
}