-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please 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-pluginIssues related to @typescript-eslint/eslint-plugin
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
export default class {
public accessor a: string = 'a'
public accessor c: string = 'c'
// Should raise an error since `b` is before `c` in the alphabetical order, but does not
public accessor b: string = 'b'
/* If you invert `b` and `e()`, the following error will be raised:
'Member null should be declared before all public instance method definitions. 16:3 - 16:34'
(what means that `b` is recognized as a non-instance method, so the rule applies well,
but it also means that the rule thinks that `b` is named `null`)
*/
public e(): void {
return
}
// Raise an error since `d` is before `e` in the alphabetical order, so the rule applies well
public d(): void {
return
}
}
ESLint Config
{
"rules": {
"@typescript-eslint/member-ordering": [
"error",
{
"default": {
"memberTypes": [
"accessor",
"method"
],
"order": "natural"
}
}
]
}
}
tsconfig
Expected Result
I expected the 7th line should report the error:
Member b should be declared before member c. 7:3 - 7:34
Actual Result
There was no error on 7th line.
Additional Info
If you invert b
and e()
, the following error will be raised:
Member null should be declared before all method definitions. 16:3 - 16:34
what means that b
is recognized as a non-method, so the rule applies well, but it also means that the rule thinks that b
is named null
.
If you invert accessor
and method
in the eslint config:
{
"rules": {
"@typescript-eslint/member-ordering": [
"error",
{
"default": {
"memberTypes": [
"method",
"accessor"
],
"order": "natural"
}
}
]
}
}
a
, b
and c
are well recognized as accessors
according to the new error messages:
Member e should be declared before all accessor definitions. 14:3 - 16:4
Member d should be declared before all accessor definitions. 19:3 - 21:4
My assumption is that each accessor
is treated as if it were named null
.
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please 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-pluginIssues related to @typescript-eslint/eslint-plugin