Skip to content

Commit

Permalink
feat: improve checking if a member is private in sort-classes rule
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 authored Aug 15, 2024
1 parent 4f3da85 commit 4e19b94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rules/sort-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ export default createEslintRule<Options, MESSAGE_ID>({
}
}

let isPrivateName = name.startsWith('#')
let isPrivateHash =
'key' in member && member.key.type === 'PrivateIdentifier'
let decorated =
'decorators' in member && member.decorators.length > 0

Expand Down Expand Up @@ -384,7 +385,7 @@ export default createEslintRule<Options, MESSAGE_ID>({

if (member.accessibility === 'protected') {
modifiers.push('protected')
} else if (member.accessibility === 'private' || isPrivateName) {
} else if (member.accessibility === 'private' || isPrivateHash) {
modifiers.push('private')
} else {
modifiers.push('public')
Expand Down Expand Up @@ -436,7 +437,7 @@ export default createEslintRule<Options, MESSAGE_ID>({

if (member.accessibility === 'protected') {
modifiers.push('protected')
} else if (member.accessibility === 'private' || isPrivateName) {
} else if (member.accessibility === 'private' || isPrivateHash) {
modifiers.push('private')
} else {
modifiers.push('public')
Expand Down Expand Up @@ -473,7 +474,7 @@ export default createEslintRule<Options, MESSAGE_ID>({

if (member.accessibility === 'protected') {
modifiers.push('protected')
} else if (member.accessibility === 'private' || isPrivateName) {
} else if (member.accessibility === 'private' || isPrivateHash) {
modifiers.push('private')
} else {
modifiers.push('public')
Expand Down

0 comments on commit 4e19b94

Please sign in to comment.