"key-spacing" tab alignment
See original GitHub issueThis 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:
- Created 4 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top GitHub Comments
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.
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:
but multiple tabs don’t make sense:
They don’t make sense because if
terriblyLongProperty
becomesfoo
you still have to update the rest of the properties, sotab
isn’t solving a real issue here.You’re just using
tab
as a replacement for 4 spaces, so you should use spaces.