-
Notifications
You must be signed in to change notification settings - Fork 201
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
Better criteria for public/private/protected methods #1514
Comments
@justinfagnani what do you think? We went with private unless documented mostly for the documentation case, but in hindsight I think that's premature, or at least overspecialized to polymer core. Better for documentation viewer to handle that I think. |
I think the suggestion here sounds reasonable. I slated it for 2.0, but it might not be blocking depending on the amount of time we have. It'd be nice to do. |
Like I said, I'm happy to take a shot at it if you want. |
Go for it! |
Ok, PR is out. Sorry for taking so long! |
cc @kevinpschaaf, @notwaldorf, and @sorvell to make sure our rules are ok |
The new rules look 👍 to me. I filed an issue on |
Fixed in #525 |
From https://github.com/Polymer/polymer-analyzer/blob/master/src/polymer/js-utils.ts#L113:
The whole idea of 'private unless documented' doesn't make a lot of sense to me. We're using two different sources of information to infer privacy.
Explicit privacy annotation via jsdoc trumps method naming, which makes sense, but why are we assuming undocumented methods are private (I know this is optional, but it's what we're using for scanning Polymer elements, for example). And why does this rule only apply to 'regular' named methods and not to pre/suffixed ones? this has the weird effect that an undocumented, 'regular' method has a higher privacy than a prefixed one:
This just seems wildly inconsistent to me. Another weird thing is that add any comment to a method makes it public.
I think if we infer privacy from method names, we should be consistent about it. I.e. in the absence of an explicit jsdoc privacy annotation:
regularMethod() {}
: public_prefixed() {}
: protected__doublePrefixed() {}
,postFixed_()
: privateOptionally we can opt out of inferring privacy from method names altogether and instead assume a default privacy, but then we should do this consistently for all kinds of methods, not just for 'regular' ones.
Here is my proposed patch:
Thoughts? I'm happy to put up a PR if you guys agree with the changes.
The text was updated successfully, but these errors were encountered: