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
Bug: key-spacing
with align: "value"
produces incorrect alignment
#16490
Comments
This looks like a bug to me.
The different behavior seems to be because in the first case eslint/lib/rules/key-spacing.js Lines 343 to 349 in 74a5af4
Perhaps we could change this logic a bit to fix the bug - if |
Thanks @mdjermanovic, I did some debugging and I think your analysis is correct. I can work on a PR to fix this. |
@fasttime Thanks for taking this up. Yes, you will have to add corresponding test cases in your PR. |
This should be fine with /* eslint "key-spacing": ["error", { align: "colon" }] */
({
command : "npm",
arguments:
[
"test"
]
}); But if we change the logic such that a value on a different line doesn't continue the group, then the rule would report a problem, and the corrected output would be: /* eslint "key-spacing": ["error", { align: "colon" }] */
({
command: "npm",
arguments:
[
"test"
]
}); Any thoughts about this @mdjermanovic? |
I think that's fine. Per the documentation (emphasize mine):
Since the value starts on another line, values wouldn't be aligned so this looks similar to the problem with |
Environment
Node version: v19.0.0
npm version: v8.19.2
Local ESLint version: v8.26.0
Global ESLint version: Not found
Operating System: darwin 22.1.0
What parser are you using?
Default (Espree)
What did you do?
DEMO
What did you expect to happen?
No error.
What actually happened?
Got error
Autofix adds three spaces after
code:
to align the value1
one space aftermessage:
, which doesn't seem correct since there is no other value to align with.If the order of the properties is swapped, as expected, no error is reported.
DEMO
Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: