Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

--fix for explicit privacies in member-access #2967

Closed
JoshuaKGoldberg opened this issue Jun 29, 2017 · 3 comments · Fixed by #2969
Closed

--fix for explicit privacies in member-access #2967

JoshuaKGoldberg opened this issue Jun 29, 2017 · 3 comments · Fixed by #2969
Milestone

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Jun 29, 2017

TypeScript code being linted

class Foo {
    member: number;
    constructor(member: number) {
        this.member = member;
    }
}

Many people coming from C# and friends assume class members to be private by default. That's not true in TypeScript. A rule that requires all constructs have an explicit privacy modifier would help a lot.

Auto-fixing logic should be easy: just add "public ".

@ajafff
Copy link
Contributor

ajafff commented Jun 29, 2017

There is member-access that does what you want except auto-fixing.

@JoshuaKGoldberg
Copy link
Contributor Author

:( oh. Whoops.

Retargeting for just auto-fixing... would you consider it valid to auto-fix to public? It would be nice to auto-detect the ability to be private or protected, but that would be a dangerous change and hard with exported constructs.

@JoshuaKGoldberg JoshuaKGoldberg changed the title Rule for explicit privacies --fix for explicit privacies in member-access Jun 29, 2017
@ajafff ajafff mentioned this issue Jun 29, 2017
4 tasks
@ajafff
Copy link
Contributor

ajafff commented Jun 29, 2017

Opened #2969 to automatically add public when fixing

@adidahiya adidahiya added this to the TSLint v5.6 milestone Aug 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants