object-shorthand rule's consistent-as-needed option does not work for certain inputs #7214
Labels
accepted
There is consensus among the team that this change meets the criteria for inclusion
archived due to age
This issue has been archived; please open a new issue for any further discussion
bug
ESLint is working incorrectly
rule
Relates to ESLint's core rules
It appears that the object-shorthand rule has a bug. Specifically, the consistent-as-needed option is not functioning properly.
The option is supposed to enforce consistent use of object shorthand syntax per object literal, and to require shorthand syntax when otherwise we would have redundant key/values.
For instance, instead of
we should be required to use
The following is still allowed
However, when using a quoted string for the key, OR a number for the key, such as:
The rule complains that we should be using shorthand. Obviously, that's not possible.
@naomiajacobs and I will submit a PR to resolve this issue.
What parser (default, Babel-ESLint, etc.) are you using?
Default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
This example is not using redudant property/key values, and should pass the consistent-as-needed option for the object-shorthand rule.
What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: