Skip to content

Commit

Permalink
refactor: improve styled components checking
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jul 24, 2023
1 parent d4dea5a commit 0e0cc4e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rules/sort-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,18 @@ export default createEslintRule<Options, MESSAGE_ID>({
groups: [],
})

let isStyledCallExpression = (identifier: TSESTree.Expression) =>
identifier.type === 'Identifier' && identifier.name === 'styled'

let isStyledComponents = (
styledNode: TSESTree.Node | undefined,
): boolean =>
styledNode !== undefined &&
styledNode.type === 'CallExpression' &&
((styledNode.callee.type === 'MemberExpression' &&
styledNode.callee.object.type === 'Identifier' &&
styledNode.callee.object.name === 'styled') ||
isStyledCallExpression(styledNode.callee.object)) ||
(styledNode.callee.type === 'CallExpression' &&
styledNode.callee.callee.type === 'Identifier' &&
styledNode.callee.callee.name === 'styled'))
isStyledCallExpression(styledNode.callee.callee)))

if (
!options['styled-components'] &&
Expand Down

0 comments on commit 0e0cc4e

Please sign in to comment.