Why multiline values restart key-spacing alignment?
See original GitHub issueMy issue resonates from the fact that key-spacing: ['error', {"align": "value"}]
rule is not compliant with Webstorm’s “align object on value” option (which can be used to automatically reformat the code).
At first I thought it’s a Webstorm issue and I reported it to JetBrains https://youtrack.jetbrains.com/issue/WEB-29680, but it appears that this behavior is not explicitly mentioned in ESLint docs. It’s only mentioned in the code comment “Non-consecutive lines form a new group”, but I’m not sure if it relates to this unjustified behavior.
What rule do you want to change? key-spacing, “align”: “value” https://eslint.org/docs/2.0.0/rules/key-spacing
Does this change cause the rule to produce more or fewer warnings? It would create less errors for Webstorm users.
How will the change be implemented? (New option, new default behavior, etc.)? Either:
- Ideally create a new option, with simplified aligning which doesn’t form a new group after multiline values, or…
- Explicitly mention in the docs that multiline values restart key-spacing alignment
Please provide some example code that this change will affect:
var obj = {
a: value,
bcde: 42,
fg: foo(), // Eslint error: Extra space before value
h: function () { // Eslint error: Extra space before value
return this.a;
},
ijkl: 'Non-consecutive lines form a new group'
};
What does the rule currently do for this code? With mentioned rule turned on, above code is currently treated as incorrect (“Eslint error: Extra space before value”), and there is no rule that would accept this.
What will the rule do after it’s changed? Instead of changing existing behavior (and confuse users that might find this current behavior useful), I’d rather add a new option for simplified aligning, that wouldn’t throw an error in such case.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
You’re using different rule in
.eslintrc.js
:It should be:
I’ve came up with a better, more minimal example (as previous one might be related with restarting alignment on new lines)