Skip to content

Commit

Permalink
Merge pull request #1814 from SUI-Components/fix-eslint-plugin-sui
Browse files Browse the repository at this point in the history
fix(packages/eslint-plugin-sui): Fix null check
  • Loading branch information
carlosvillu authored Aug 30, 2024
2 parents e0801e5 + 4822d16 commit e733585
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/eslint-plugin-sui/src/utils/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ function getDecoratorsByNode(node, {isAClass, isAMethod, isArrowFunction}) {

function getElementName(node, {isAClass, isAMethod, isArrowFunction}) {
if (isAClass) {
const className = node.id?.name ?? 'UnknownClass'
const className = node?.id?.name ?? 'UnknownClass'
return `${className}`
}

if (isArrowFunction) {
const methodNode = node.parent
const classNode = methodNode?.parent?.parent
const className = classNode.id?.name ?? 'UnknownClass'
const className = classNode?.id?.name ?? 'UnknownClass'
const methodName = methodNode.key?.name ?? 'UnknownMethod'

return `${className}.${methodName}`
}

if (isAMethod) {
const classNode = node.parent?.parent
const className = classNode.id?.name ?? 'UnknownClass'
const className = classNode?.id?.name ?? 'UnknownClass'
const methodName = node.key?.name ?? 'UnknownMethod'

return `${className}.${methodName}`
Expand All @@ -55,7 +55,7 @@ function getElementMessageName(elementName, {isAClass, isAMethod, isArrowFunctio

function remarkElement(node, {isAClass, isAMethod, isArrowFunction}) {
if (isAClass) {
return node.id
return node?.id
}

if (isArrowFunction) {
Expand Down

0 comments on commit e733585

Please sign in to comment.