-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[member-ordering] support abstract methods #395
Comments
Abstract methods/props were never implemented in this rule. typescript-eslint/packages/eslint-plugin/src/rules/member-ordering.ts Lines 184 to 187 in 3b28cac
|
I agree adding support for abstract methods/props would be a new feature but I think treating them as private ones is a bug in the plugin logic. It should ignore method/prop types it doesn't recognize and not misreport them as |
Yeah, it's a bug with the error message. |
Hi, I am having problems with my abstract classes and weird error messages, is there a workaround to stop the erroneous error messages? For example:
The only method definitions are the getters, and they are after
If I change the order to:
the error goes away, but |
as mentioned - the error message is incorrect. There is no handling for abstract members. This causes the error message to be wrong. |
This is the first major problem I encountered, hope it can be fixed soon :) Sorry I don't have enough skill to help yet, thanks to you and all the community for making typescript-eslint awesome. |
Shouldn't this be labelled as a |
There is a bug with the error message, sure, but this issue is asking for (intentionally) unimplemented logic to be added (as per #395 (comment)), hence enhancement. |
But there shouldn't be any error messages just because there happen to be As @mgol mentioned, if you're not ready to add support for abstract members, then this rule should simply ignore them for now. Setting that aside, couldn't |
I mean, it's really just bikeshedding - it doesn't matter if it's classed as a bug or a feature - doesn't change the fact that abstract things were not implemented. That's a question for people that actually use the rule. I don't personally use the rule, so I don't have an opinion about how it should sort things. There are two choices - either If pushed, I guess I'd lean toward the former, because I assume that the original author's intention was the former (hence they opted to skip implementation in their initial implementation). Happy to accept a PR with either. |
IMO, the first option is the feature request, and the 2nd option is the bug fix. I agree that option 1 is the better option, as it would allow developers to position abstract members differently to non-abstract members, which could result in more consistent ordering. Looking at the code, could |
I believe it could be treated as a new scope, i.e same as instance/static. |
I created a PR to add support of abstract members to the member-ordering rule, would love a review please. #1004 |
abstract class Foo {
public abstract name: string;
constructor() {}
public bar(): void {};
} This code with default member-ordering rule config (
But if I remove abstract property Is it a bug? |
Repro
Expected Result
No error
Actual Result
Additional Info
Abstract methods are not necessarily private methods. There are two issues here:
This came up when I tried to migrate my TSLint config containing:
and I failed due to errors around abstract methods handling.
Versions
@typescript-eslint/eslint-plugin
1.5.0
@typescript-eslint/parser
1.5.0
TypeScript
3.3.4000
ESLint
5.15.3
node
v8.15.1
npm
yarn
1.15.2
The text was updated successfully, but these errors were encountered: