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

[explicit-member-accessibility] "explicit" option suggestions #4647

Closed
3 tasks done
alumni opened this issue Mar 8, 2022 · 3 comments
Closed
3 tasks done

[explicit-member-accessibility] "explicit" option suggestions #4647

alumni opened this issue Mar 8, 2022 · 3 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@alumni
Copy link

alumni commented Mar 8, 2022

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/explicit-member-accessibility": "error"
  }
}
export class Dog {
    bark() {
        console.log('woof!');
    }
}

Expected Result

The method bark() is missing the accessibility modified. eslint --fix should add public.

Actual Result

The method bark() is missing the accessibility modified. eslint --fix cannot automatically fix this.

Additional Info

The docs https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md#attributes mention this rule is fixable. This only works for { accessibility: 'no-public' } but not for { accessibility: 'explicit' } (which is the default).

Versions

package version
@typescript-eslint/eslint-plugin 5.14.0
@typescript-eslint/parser 5.14.0
TypeScript 4.6.2
ESLint 8.10.0
node 16.14.0
@alumni alumni added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 8, 2022
@alumni alumni changed the title [explicit-member-accessibility] rule not fixable [explicit-member-accessibility] "explicit" option not fixable Mar 8, 2022
@bradzacher
Copy link
Member

This is by design.
The rule is not intended to automatically add public everywhere for you - it is intended to make you think about what accessibility you should be using for your members.

Is public really the right accessibility to use for the member you just wrote?

If we simply autofixed every case to public then it would defeat the purpose of the rule.

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed triage Waiting for maintainers to take a look labels Mar 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title [explicit-member-accessibility] "explicit" option not fixable [explicit-member-accessibility] "explicit" option suggestions Aug 24, 2022
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed working as intended Issues that are closed as they are working as intended labels Aug 24, 2022
@JoshuaKGoldberg
Copy link
Member

Reopening per #5492 to track that we'd accept a suggestion fixer.

@typescript-eslint typescript-eslint unlocked this conversation Aug 24, 2022
@bradzacher
Copy link
Member

Closed in #5492

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants