This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
new rule: enforce one of the two Underscore function call forms #44
Milestone
Comments
Sounds good to me. I prefer the 2nd one too. |
HamletDRC
changed the title
Rule for enforcing one of the two Underscore function call forms
new rule: enforce one of the two Underscore function call forms
Oct 12, 2015
Does this apply to all Underscore methods ? Or should it apply to only a subset of the methods (like the ones for collections (http://underscorejs.org/#collections) ? |
I would say collections and arrays (at least) |
Not sure if we can enable this rule... : I just discovered that this code does not build : function foo(dic: _.Dictionary<number>) : void {
_(dic).forEach((val: number, key: string): void => {});
} Error is :
Whereas this one does build : function foo(dic: _.Dictionary<number>) : void {
_.forEach(dic, (val: number, key: string): void => {});
} I don't know if this is an error in underscore.d.ts ... I have to check. |
Might be a bug in our d.ts. file. This works: _.forEach([1, 2, 3], function(num) { console.log(num); })
_([5, 6, 7]).forEach(function(num) { console.log(num); }) Test it here: https://jsfiddle.net/kms3y8b8/. Enable developer tools to see the output and click on Run. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What do you think of creating a rule for enforcing one of the two forms of Underscore functions? Should we create a rule for this?
Personally, I prefer the second form.
The text was updated successfully, but these errors were encountered: