-
-
Notifications
You must be signed in to change notification settings - Fork 75
New: Accessibility Modifiers (fixes #87) #88
Conversation
Thanks for the pull request, @dannyfritz! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
a756c19
to
c152007
Compare
LGTM |
c152007
to
5908e5e
Compare
LGTM |
5908e5e
to
fb220e3
Compare
LGTM |
fb220e3
to
07d279d
Compare
LGTM |
07d279d
to
53b7cbe
Compare
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this, Danny! This is really coming together
* Gets a TSNode's accessibility level | ||
* @returns {string} accessibility "public", "protected", or "private" | ||
*/ | ||
function getTSNodeAccessibility() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a minor point, but I would usually prefer that TSNode be passed into the helper function so that it is a bit more portable.
I'm sure we'll be refactoring some of this code once the project is a bit more mature and things like this will make that process easier.
protected setBar (bar : string) { | ||
this.bar = bar; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add at least one example of methods and properties which have multiple TS modifiers on them:
e.g.
class X {
public static yo: string = 'Init';
protected get bye() {
return 'bye';
}
}
@@ -420,6 +420,8 @@ module.exports = function(ast, extra) { | |||
return null; | |||
} | |||
|
|||
var accessibility; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this line. I'm going to have it always set the accessibility
and just have it default to null
instead to clean up code.
I'm noticing Also, there is a shorthand in TS for specifying members in the |
53b7cbe
to
5905cd4
Compare
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor
should have an accessibility of "public"
.
I'm not sure what you mean by this. Can you please point me to an example? Everything in a TypeScript class is public by default (just like a standard ES2015 class), we will only worry about adding |
Yes, we will need to handle this behaviour in a separate PR as it will require some discussion. Thanks for flagging though! |
Alright, if we're only concerned with explicit accessibility keywords then this should be good. |
RE: The constructor: Oh, I missed this comment from you:
...and I can see you have already updated all the relevant existing ASTs. @nzakas What do you think about this change? If we do go with Danny's latest changes which adds "accessibility" to everything, then constructor should probably have it too |
Ok great, sorry I missed that discussion earlier in the week as I was travelling |
So, to summarise, I still thinks it makes sense to keep the |
This LGTM now! I'll leave it to @nzakas to merge to double check he is happy with "accessibility" over "visibility". We usually try and match existing ESTree or Flow constructs wherever possible, but these modifiers do not exist on classes for them yet. I therefore think it makes sense to go with TypeScript's term of "accessibility", as in this PR. Thanks again, @dannyfritz! |
I'm going to add accessibility to the constructor too. null still if nothing is specified. Then i think this PR is ready. |
Totally agree.
Eh, I don't have the energy to argue this point, so it's fine. :) @dannyfritz it looks like you're still planning on making changes? Can you let us know when you do? |
5905cd4
to
a0ef527
Compare
LGTM |
Alright. This PR is ready for review. |
Thanks, @dannyfritz! This still LGTM. |
Issue (#87)
This pull request is about getting the
public
,protected
, andprivate
keywords into the ESLint AST.The accessibility modifier keywords can appear on
ClassProperty
andMethodProperty
.http://astexplorer.net/#/FfIL8GurdC