Closed MohnJcAfee closed 9 months ago
When given a custom sort order for sort-classes, private methods (with #) syntax are not sorted properly but rather the # seems to be interpreted as just another character.
Order set in eslint config:
"perfectionist/sort-classes": [ "error", { "type": "natural", "order": "asc", "groups": [ "static-property", "private-property", "property", "constructor", "method", "private-method", "static-method", "other" ] } ]
The following unsorted class:
class MyUnsortedClass { someOtherProperty someProperty = 1 constructor() {} static #aPrivateStaticMethod () {} #somePrivateProperty #someOtherPrivateProperty = 2 static someStaticProperty = 3 static #someStaticPrivateProperty = 4 aInstanceMethod () {} static aStaticMethod () {} #aPrivateInstanceMethod () {} }
results in the following order:
class MyUnsortedClass { static #someStaticPrivateProperty = 4 static someStaticProperty = 3 #someOtherPrivateProperty = 2 #somePrivateProperty someOtherProperty someProperty = 1 constructor() {} #aPrivateInstanceMethod () {} aInstanceMethod () {} static #aPrivateStaticMethod () {} static aStaticMethod () {} }
the private instance method is above the instance method despite the group having a different order. It should be:
aInstanceMethod () {} #aPrivateInstanceMethod () {}
8.48.0
1.5.1
it seems the # is not interpreted as "private" but rather just as a character in sorting static/regular methods and properties
Thanks for the issue! It's good idea, i think it will be implemented soon.
Fixed in c00ac107411d86c25a0cf5a0b87fa2c2845c8176.
Release is coming soon.
Released in v2.0.0
Describe the bug
When given a custom sort order for sort-classes, private methods (with #) syntax are not sorted properly but rather the # seems to be interpreted as just another character.
Code example
Order set in eslint config:
The following unsorted class:
results in the following order:
the private instance method is above the instance method despite the group having a different order. It should be:
ESLint version
8.48.0
ESLint Plugin Perfectionist version
1.5.1
Additional comments
it seems the # is not interpreted as "private" but rather just as a character in sorting static/regular methods and properties
Validations