Skip to content

[class-literal-property-style] should not fix readonly to getter when assigned in ctor #2206

@k3nsei

Description

@k3nsei

Repro

Playground

{
  "rules": {
    "@typescript-eslint/class-literal-property-style": ["error", "getters"],
    "@typescript-eslint/prefer-readonly": "warn"
  }
}
export class A {
  private readonly foo: string = 'bar';

  constructor(foo: string) {
    this.foo = foo;
  }
}

Expected Result
Code should be unchanged

Actual Result
Code after fix is invalid

export class A {
  private get foo() { return 'bar'; }

  constructor(foo: string) {
    this.foo = foo;
  }
}

Additional Info
None

Versions

package version
@typescript-eslint/eslint-plugin 3.2.0
@typescript-eslint/parser 3.2.0
TypeScript 3.9.5
ESLint 7.2.0
node 14.2.0
npm 6.14.5
yarn 1.22.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerslocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions