Skip to content

Commit

Permalink
feat(packages/eslint-plugin-sui): check if arrow function as a getter
Browse files Browse the repository at this point in the history
  • Loading branch information
aleixferr committed Jul 22, 2024
1 parent 3cd13fe commit 6310ab2
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ module.exports = {
const allowedWords = ['VO', 'ValueObject', 'Entity']
const isDomainModelName = allowedWords.some(allowWord => className.includes(allowWord))

if (!isDomainModelName || !isValueObjectPath || !isEntityPath) return // eslint-disable-line
if (!isDomainModelName && !isValueObjectPath) return
if (!isDomainModelName && !isEntityPath) return

// Check if all attributes are public
const publicAttributes = node.body.body.filter(node => {
return node.type === 'PropertyDefinition' && node.key.type === 'Identifier'
return node.type === 'PropertyDefinition' && node.key.type === 'Identifier' && node.value?.type !== 'ArrowFunctionExpression'
})

publicAttributes.forEach(attribute => {
Expand All @@ -67,7 +68,9 @@ module.exports = {
const privateAttributes = node.body.body.filter(node => {
return node.type === 'PropertyDefinition' && node.key.type === 'PrivateIdentifier'
})
const classMethods = node.body.body.filter(node => node.type === 'MethodDefinition')
const classMethods = node.body.body.filter(node => {
return node.type === 'MethodDefinition' || node.value?.type === 'ArrowFunctionExpression'
})

privateAttributes.forEach(attribute => {
let hasGetter = false
Expand Down

0 comments on commit 6310ab2

Please sign in to comment.