Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary formatting sometimes uses spaces instead of tabs #15655

Closed
epmatsw opened this issue Nov 13, 2023 · 0 comments · Fixed by #15662
Closed

Ternary formatting sometimes uses spaces instead of tabs #15655

epmatsw opened this issue Nov 13, 2023 · 0 comments · Fixed by #15662
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@epmatsw
Copy link

epmatsw commented Nov 13, 2023

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
			}
		/>
	);
};
@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program lang:javascript Issues affecting JS labels Nov 22, 2023
ybiquitous added a commit to stylelint/stylelint-demo that referenced this issue Dec 6, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Mar 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants