Skip to content

Commit

Permalink
fix: errors on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Thebarda authored and hiukky committed Oct 11, 2021
1 parent de4c9db commit a6b8c20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rules/sort/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ module.exports = {

if (isExportableDeclaration()) {
declarations =
node['declaration']['declarations']?.[0]['init'] ||
node['declaration']?.['declarations']?.[0]['init'] ||
node['declaration']
} else {
declarations = node['declarations']?.[0]['init'] || node
}

return declarations['body']?.['body']
return declarations?.['body']?.['body']
})
.filter(Boolean)
.forEach((declarations: Node[]) => {
let nodes: Node[] = []

declarations.forEach(node => {
declarations.forEach?.(node => {
if (node['type'] === 'ExpressionStatement') {
nodes.push(node['expression'])
}
Expand All @@ -98,7 +98,7 @@ module.exports = {
const getHookName = (): string =>
type === 'CallExpression'
? declaration.name
: declaration.callee.name
: declaration.callee?.name

const getHookNode = (): Node =>
type === 'CallExpression' ? declaration : declaration.callee
Expand Down

0 comments on commit a6b8c20

Please sign in to comment.