Skip to content

Ternary formatting sometimes uses spaces instead of tabs #15655

@epmatsw

Description

@epmatsw

After updating to 3.1.0 with the default ternary formatting, Prettier is sometimes using spaces for indentation even if it's configured to use tabs.

Prettier 3.1.0
Playground link

{
  "arrowParens": "always",
  "bracketSameLine": false,
  "bracketSpacing": true,
  "semi": true,
  "singleQuote": false,
  "jsxSingleQuote": false,
  "quoteProps": "as-needed",
  "trailingComma": "all",
  "singleAttributePerLine": false,
  "htmlWhitespaceSensitivity": "css",
  "vueIndentScriptAndStyle": false,
  "proseWrap": "preserve",
  "insertPragma": false,
  "printWidth": 80,
  "requirePragma": false,
  "tabWidth": 2,
  "useTabs": true,
  "embeddedLanguageFormatting": "auto"
}

Input:

const Blah = () => {
		return (
					<a
						c={
							loooooooooooooooooong
								? alsolooooooong
									? gaaaaaaaaa
									: ggggggggg
									? b
									: c
								: d
						}
					/>
		);
	}

Output:

const Blah = () => {
	return (
		<a
			c={
				loooooooooooooooooong
					? alsolooooooong
						? gaaaaaaaaa
						: ggggggggg
						  ? b
						  : c
					: d
			}
		/>
	);
};

Expected behavior:

It should always use tabs.

const Blah = () => {
	return (
		<a
			c={
				loooooooooooooooooong
					? alsolooooooong
						? gaaaaaaaaa
						: ggggggggg
							? b
							: c
					: d
			}
		/>
	);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions