Open
Description
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
Repro Code
class Test1 {
// should not report
private prop = 7;
foo() {
this['prop'] = 10;
}
}
class Test2 {
// should report
private [Symbol.iterator] = 7;
}
class Test3 {
// should not report
private 'prop' = 7;
foo() {
this.prop = 10;
}
}
class Test4 {
// should report?
private [1] = 7;
}
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/prefer-readonly": "error",
},
};
tsconfig
Expected Result
I expected the rule not to report the first example and third examples and to report on the second and forth examples.
Actual Result
The rule reports on the first example, with the auto-fixer creating a type error: Cannot assign to 'prop' because it is a read-only property.
.
The second example should be reported but is missed.
The third example should not be reported, and also creates a type error once auto-fixed.
The forth example (I think) should be reported but it's missed.
Additional Info
I think this is very similar to #10211, and I noticed this while working on #10552. I think at least some of these can be tackled with getStaticMemberAccessValue
.