Skip to content
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

fix(eslint-plugin)!: [explicit-member-accessibility] Stop checking parameter properties #631

Closed

Conversation

ankeetmaini
Copy link
Contributor

@ankeetmaini ankeetmaini commented Jun 21, 2019

BREAKING CHANGE: changes rule config

Fixes #617
Fixes #857

@ankeetmaini
Copy link
Contributor Author

I am not sure why coverage went down. I added the test cited in the issue and worked my way of figuring out the solution. I am not sure if my approach is correct. Do let me know! Thanks :)

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless I'm mistaken, a parameter property is always considered valid under this rule because it always MUST have an accessibility modifier, or else it's not a parameter property?

In that case can't you can just remove the TSParameterProperty selector from the rule altogether, because there's no situation that this rule should check them?

@ankeetmaini
Copy link
Contributor Author

@bradzacher thanks, I didn't know about it! I've removed the selector, edited some failing tests and rebased the PR with master.

@bradzacher bradzacher changed the title Honour override "off" for constructor param properties fix(eslint-plugin): [explicit-member-accessibility] Stop checking parameter properties Jun 22, 2019
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last change - remove the parameterProperties option from the interface and the json schema

@ankeetmaini
Copy link
Contributor Author

Done!

@ankeetmaini
Copy link
Contributor Author

I've to update the doc as well. Will do that and update here shortly.

bradzacher
bradzacher previously approved these changes Jun 23, 2019
@bradzacher bradzacher added the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Jun 23, 2019
@bradzacher bradzacher added breaking change This change will require a new major version to be released bug Something isn't working labels Jun 28, 2019
@bradzacher bradzacher added this to the 2.0.0 milestone Jun 28, 2019
@ark120202
Copy link

Parameter properties also can be declared with a readonly modifier:

class Foo {
  constructor(readonly bar: string) {}
}

So the change there should be:

-if (paramPropCheck === 'no-public' && node.accessibility === 'public') {
+if (paramPropCheck === 'no-public' && node.accessibility === 'public' && !node.readonly) {

It also currently doesn't enforce it with explicit, but that's a different issue.

@bradzacher bradzacher changed the title fix(eslint-plugin): [explicit-member-accessibility] Stop checking parameter properties fix(eslint-plugin)!: [explicit-member-accessibility] Stop checking parameter properties Jul 21, 2019
@JamesHenry
Copy link
Member

@ankeetmaini we are currently preparing the v2 release (i.e. breaking changes are currently eligible to be merged) when do you think you will have chance to make the change suggested by @ark120202?

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@bradzacher bradzacher removed the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Jul 22, 2019
@bradzacher bradzacher modified the milestones: 2.0.0, 3.0.0 Jul 25, 2019
@ankeetmaini
Copy link
Contributor Author

I totally missed the above comment, apologies. So for the above mentioned change, I'll have to undo the removal of parameterProperties , correct? Just confirming.

@bradzacher
Copy link
Member

yes, I was wrong, sorry.
I completely forgot about the readonly only case.

Unless I'm mistaken - these should be the states:

valid when parameterProperties: 'off':

  • private/protected/public foo
  • private/protected/public readonly foo
  • readonly foo

valid when parameterProperties: 'explicit':

  • private/protected/public foo
  • private/protected/public readonly foo
    invalid:
  • readonly foo

valid when parameterProperties: 'no-public':

  • private/protected/public foo
  • private/protected readonly foo
  • readonly foo
    invalid:
  • public readonly foo

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Aug 7, 2019
@ankeetmaini
Copy link
Contributor Author

Closing this in favour of #912

@bradzacher bradzacher removed this from the 3.0.0 milestone Dec 3, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party breaking change This change will require a new major version to be released bug Something isn't working
Projects
None yet
4 participants