You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
The object-literal-shorthand rule currently does not offer granularity for enforcing/disallowing shorthand separately for property assignment vs method declarations.
I would prefer to allow (but not enforce!) shorthand for method declarations, but disallow shorthand for property assignments.
Here's an example of how I would like to configure the object-literal-shorthand rule:
constsomeValue=20;constmyObj={// error: shorthand property assignment not allowed
someValue,// validanotherValue: someValue,// validsomeMethod(): number{return42;},// also validanotherMethod: (): number=>{return42;}};
The motivation for this is that shorthand method declaration is very convenient and improves readability, while shorthand property assignment creates a coupling between the object's property name and a local variable name that can lead to bugs when refactoring code later.
The text was updated successfully, but these errors were encountered:
Note: per #4534, this issue will be closed in less than a month if no PR is sent to add the rule. If you really need the rule, custom rules are always an option and can be maintained outside this repo!
The
object-literal-shorthand
rule currently does not offer granularity for enforcing/disallowing shorthand separately for property assignment vs method declarations.I would prefer to allow (but not enforce!) shorthand for method declarations, but disallow shorthand for property assignments.
Here's an example of how I would like to configure the
object-literal-shorthand
rule:The motivation for this is that shorthand method declaration is very convenient and improves readability, while shorthand property assignment creates a coupling between the object's property name and a local variable name that can lead to bugs when refactoring code later.
The text was updated successfully, but these errors were encountered: