In JavaScript, I like the naming convention of PascalCase for constructor functions and camelCase for other functions. It looks like ReSharper is configured for these settings. However, for code like this:
function Thing(a, b) {
return {
prop1: a,
prop2: b
};
}
var thing = new Thing(2, 6);
...I receive this warning:
Name 'Thing' does not not match rule 'Local Function'. Suggested name is 'thing'.
It doesn't make a difference if I change Thing
to this:
function Thing(a, b) {
this.prop1 = a;
this.prop2 = b;
}
I suspect that only "public" functions are considered constructors. Do any of you know how ReSharper differentiates between a "Local" and "Constructor" function? Even better, do you know how to override this behavior?
Well, this is a bug in ReSharper. You can wait or fix it yourself. Or define it in global scope.
Btw, those functions do very, very different things. You definitely don't want to call the former a constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With