Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked 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
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
{"rules": {"@typescript-eslint/class-literal-property-style":"warn" }}
abstractclassBaseClass{// class-literal-property-style error; this one is fair, because it isn't entirely aware// that I'm going to override it, so this one I can see just being an eslint disablegetcursor():string|string[]{return'crosshair';}readonlyhidden:boolean=false;abstractgeticon():string;}classChildClassextendsBaseClass{// class-literal-property-style error// this one, however, is interesting because it should know that it is// overriding an existing getter and can't be made a literaloverridegetcursor(){return'square';}readonlyhidden:boolean=truereadonlyicon='circle'something:boolean}
Expected Result
ESLint shouldn't suggestclass-literal-property-style
when overriding a getter, because it is not possible to turn an inherited getter into a readonly property (ts(2610))
Actual Result
It suggests breaking the code by attempting to convert the children into a literal when it is not possible. Conversely, it suggests converting the base class one into a literal, which will not work for children that need to use a getter for conditional return values (ts(2611)).
Additional Info
As a side-issue, this rule is not enum-aware and does not trigger if the literal returned from a getter is an enum value:
enumTest{Value}classTestClass{// should trigger heregettest(){returnTest.Value;}}
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 8.2.1 |
@typescript-eslint/parser | 8.2.1 |
TypeScript | 4.3.4 |
ESLint | 7.28.0 |
node | 14.8.0 |
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked 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