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

Different indentation for "continuation indents/wrapped lines" #11897

Closed
dvlato opened this issue Dec 1, 2021 · 2 comments
Closed

Different indentation for "continuation indents/wrapped lines" #11897

dvlato opened this issue Dec 1, 2021 · 2 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@dvlato
Copy link

dvlato commented Dec 1, 2021

Many style guides set a different indentation (eg. *2 tabWidth) for wrapped lines/ continuation indents; since Prettier does not want any new configurable option; Could we please add a different default for continuation indents?

See the prettier example, where I would like "this.line.is.very.long()" and "bodyOfBlock()" to have different indentation:

Prettier 2.5.0
Playground link

--parser babel
--arrow-parens avoid
--trailing-comma none

Input:

if (this.line.is.very.long()
  && more.code.here(running + out, ofIdeas, wrapAlready)) {
  bodyOfBlock();
}
const similarilyAssumingLongVariableNames =
  someValue;

Output:

if (
  this.line.is.very.long() &&
  more.code.here(running + out, ofIdeas, wrapAlready)
) {
  bodyOfBlock();
}
const similarilyAssumingLongVariableNames = someValue;

Expected behavior:

if (
    this.line.is.very.long() &&
    more.code.here(running + out, ofIdeas, wrapAlready)
) {
  bodyOfBlock();
}

Elements inside the IF block have a 4 character indentation instead of the 2 for "bodyOfBlock()"

@alexander-akait
Copy link
Member

Sorry, we don't want to add more options, please read https://prettier.io/docs/en/option-philosophy.html

@dvlato dvlato changed the title Option to configure indentation for "continuation indents/wrapped lines" Different indentation for "continuation indents/wrapped lines" Dec 1, 2021
@James-Richardson
Copy link

The Google Style Guide says that continuation indents should be 4 spaces: https://google.github.io/styleguide/jsguide.html#formatting-indent.

And in my experience, having a continuation indent that's twice the normal indent is common enough that I considered it a de facto standard.

Can you please explain why Prettier necessarily sets the continuation indent to 2 spaces instead of 4?

Is it a preference of Prettier users?

Is the industry as a whole moving to 2 space continuation indents?

Is it an oversight in Prettier that has gone uncorrected for so long that it is now too late to change it?

Or does no one know why the continuation indent in Prettier is 2 spaces, it just is?

@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 Nov 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

3 participants