-
Notifications
You must be signed in to change notification settings - Fork 889
member-access: Clean up and add "no-public" option. #2247
Conversation
let checkConstructor = options.indexOf(OPTION_CHECK_CONSTRUCTOR) !== -1; | ||
if (noPublic) { | ||
if (checkAccessor || checkConstructor) { | ||
throw new Error("If 'no-public' is present, it should be the only option."); |
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.
Config error should state rule name like:
"member-access
rule: the no-public
option cannot be combined with other options"
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 disagree; rules shouldn't have to state their name. It should just be the default to include the name of the failing rule in the output. See #2228.
let checkAccessor = options.indexOf(OPTION_CHECK_ACCESSOR) !== -1; | ||
let checkConstructor = options.indexOf(OPTION_CHECK_CONSTRUCTOR) !== -1; | ||
if (noPublic) { | ||
if (checkAccessor || checkConstructor) { |
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 can compile a private constructor and private getter
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.
This checks that when no-public
is set, check-accessor
and check-constructor
aren't set, because someone who wants to ban the public
keyword presumably wants to ban it everywhere, so we always check everything, so other options aren't necessary.
@andy-hanson thanks! |
So happy to have this rule. Thank you! |
Probably we didn't understand well the rule but for me this is to don't use 'public' because is default value in TS.
|
@CKGrafico do you use tslint 5.0.0 or greater? |
PR checklist
Overview of change:
Added a
no-public
option tomember-access
.Also removed documentation about
constructor
andget/set
only being public, because this appears to not be true any more.CHANGELOG.md entry:
[new-rule-option]
member-access
addsno-public
option