Skip to content

Enhancement: [prefer-readonly] check #private class fields #7126

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

Closed
4 tasks done
danielrentz opened this issue Jun 21, 2023 · 0 comments · Fixed by #7686
Closed
4 tasks done

Enhancement: [prefer-readonly] check #private class fields #7126

danielrentz opened this issue Jun 21, 2023 · 0 comments · Fixed by #7686
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@danielrentz
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&sourceType=module&showAST=es&code=MYGwhgzhAEAqCmEAu0DeBYAUNaAHATgJYBuYS80A+gB7QC80AjANxY4DEAnvU65m9ADm8FNQAUASjTR8IgK74AdtCQALQhAB0NZtAC+A4Sk6TpspAuVqNmrroOY9QA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0Wls4CGAEwD2TeIXRRe0EdEjgwAXxBKgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

class Test {
  private _x = 1;
  #y = 1;

  get x() { return this._x; }
  get y() { return this.#y; }
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/prefer-readonly": "error"
  },
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

Triggers on private field and #field class fields.

Actual Result

Triggers on private field but not on #field class fields.

Additional Info

No response

@danielrentz danielrentz added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jun 21, 2023
@bradzacher bradzacher added enhancement: plugin rule option New rule option for an existing eslint-plugin rule accepting prs Go ahead, send a pull request that resolves this issue and removed bug Something isn't working triage Waiting for team members to take a look labels Jun 21, 2023
@bradzacher bradzacher changed the title Bug: [prefer-readonly] Does not check #private class fields Enhancement: [prefer-readonly] check #private class fields Jun 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2023
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 enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants