question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spaces are not being used to align variables in Javascript var statement

See original GitHub issue

Prettier 1.18.2 Playground link

--parser babylon
--single-quote
--tab-width 4
--use-tabs

Input:

function test() {
	var bla,
	    zever = 1;
}

Output:

function test() {
	var bla,
		zever = 1;
}

Expected behavior:

The original tab whitespace directly in front of zever is used for positioning, not for indenting. Prettier should NOT replace that with a tab because it breaks the positioning (as you can see on this page, where tabs are 8 characters wide)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lydellcommented, Mar 3, 2020

Someone on my team keeps on using prettier, while the rest of us don’t. Whenever he commits something, ALL the spaces get turned into tabs, which pollutes the diff a lot more

Then you have a very simple solution to your problem: Ask this person to stop using Prettier! Tell them that it causes unnecessary diff which makes PRs harder to review and increases the risk of merge conflicts.

0reactions
no-response[bot]commented, Mar 17, 2020

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript Best Practices — Spacing and Variables
Horizontal whitespace usage depends on location. We should never have trailing whitespaces. We should have whitespace to separate reserved words ...
Read more >
Auto align "var" under JavaScript in PhpStorm (7.0.1)
First of all: Settings > Code Style > JavaScript > Other > Align object properties: On value has nothing to do with variable...
Read more >
Multiple var statements in JavaScript, not superfluous
Of course, there's always the tabs-vs-spaces argument. Which looks better when declaring multiple variables in a single var statement, tabs or ...
Read more >
var() - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The var() CSS function can be used to insert the value of a custom property (sometimes called a "CSS variable") instead of any...
Read more >
JavaScript var Statement - W3Schools
var carName;. After the declaration, the variable is empty (it has no value). To assign a value to the variable, use the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found