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.

"key-spacing" tab alignment

See original GitHub issue

This revisits issues #1727 and #9523.

What rule do you want to change? key-spacing

Does this change cause the rule to produce more or fewer warnings? The proposed change will cause the rule to produce fewer warnings because it will allow the rule to accept tabs as indentation for alignment.

How will the change be implemented? (New option, new default behavior, etc.)? An additional option, tabs, would be added, allowing the user to specify whether tabs would be required for alignment indentation, and, if so, how many spaces they should be considered as.

Please provide some example code that this change will affect:

// New behavior; allows for tabs with an assumed width of 4 spaces.
/*eslint key-spacing: ["error", { "tab": 4 }]*/
const myObject = {
    property:<tab><tab>value,
    anotherProperty:<tab>value2
};

// Default behavior; disallows tabs. This will raise a warning.
/*eslint key-spacing: ["error", { "tab": "never" }]*/
const myObject = {
    property:<tab><tab>value,
    anotherProperty:<tab>value2
};

What does the rule currently do for this code? The rule currently does not treat tabs as valid whitespace for alignment, let alone calculate their width.

What will the rule do after it’s changed? After the proposed change, the rule would allow the use of tab characters to more easily align properties.

Are you willing to submit a pull request to implement this change? Yes.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bren0xacommented, Nov 11, 2019

Sure, I’d gladly work on this. It might be a while before I’ll have a PR, since I’m a little swamped right now.

0reactions
fregantecommented, Jan 9, 2020

If you expect tabs to be a certain length, you should use spaces.

I’m all for tabs-for-indentation, but here they’re wrong. It would be great if editors automatically aligned one tab like word processors can:

{
	a:           ->          10,
	terriblyLongProperty: -> 91
}

but multiple tabs don’t make sense:

{
	a:   ->   ->   ->   ->   10,
	terriblyLongProperty: -> 91
}

They don’t make sense because if terriblyLongProperty becomes foo you still have to update the rest of the properties, so tab isn’t solving a real issue here.

 {
- 	a:   ->   ->   ->   ->   10,
- 	terriblyLongProperty: -> 91
+	a:  ->  10,
+ 	foo: -> 91
 }

You’re just using tab as a replacement for 4 spaces, so you should use spaces.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adjust alignment and spacing in Keynote for iCloud
In Keynote for iCloud, align text in text boxes and adjust the spacing and indentation of lines and paragraphs.
Read more >
Bootstrap align tab-content accordingly - Stack Overflow
How can i make the tab-content fit rightly into the bordered div? i need somehow to maintain a smilar structure since i use...
Read more >
Right Alignment of text - tabbing - LaTeX Stack Exchange
Right Alignment of text ... You're not actually using any tab stops though. ... Keyspace in Encryption using Chaotic Maps.
Read more >
Developers Who Use Spaces Make More Money Than Those ...
@sullivan modern editors make spaces instead of tabs, but also… Using spaces to align code, especially when declaring class properties, JSON ...
Read more >
yml/key-spacing | eslint-plugin-yml
yml/key-spacing: - error - beforeColon: false afterColon: true mode: strict # or "minimum" # "align": "value" or "colon" # "singleLine": ...
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