Skip to content

Commit

Permalink
fixed test case issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmadFaraz-crypto committed May 6, 2024
1 parent 7eff65a commit d9f9d4e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/unminify/src/transformations/un-jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { generateName } from '@wakaru/ast-utils/identifier'
import { isNull, isTrue, isUndefined } from '@wakaru/ast-utils/matchers'
import { removeDeclarationIfUnused } from '@wakaru/ast-utils/scope'
import { nonNullable } from '@wakaru/shared/array'
import { createJSCodeshiftTransformationRule } from '@wakaru/shared/rule'
import { z } from 'zod'
import type { ASTTransformation } from '@wakaru/shared/rule'
import { createJSCodeshiftTransformationRule } from '@wakaru/shared/rule'

Check failure on line 9 in packages/unminify/src/transformations/un-jsx.ts

View workflow job for this annotation

GitHub Actions / check

`@wakaru/shared/rule` import should occur before type import of `@wakaru/shared/rule`
import type { ExpressionKind, LiteralKind } from 'ast-types/lib/gen/kinds'
import type { ASTNode, ASTPath, CallExpression, Collection, Identifier, JSCodeshift, JSXAttribute, JSXElement, JSXExpressionContainer, JSXFragment, JSXIdentifier, JSXMemberExpression, JSXSpreadAttribute, JSXSpreadChild, JSXText, MemberExpression, RestElement, SpreadElement, StringLiteral, VariableDeclarator } from 'jscodeshift'
import { z } from 'zod'

Check failure on line 12 in packages/unminify/src/transformations/un-jsx.ts

View workflow job for this annotation

GitHub Actions / check

`zod` import should occur before type import of `@wakaru/shared/rule`

export const Schema = z.object({
pragma: z.string().optional().describe('The pragma to use for JSX transformation.'),
Expand Down Expand Up @@ -253,11 +253,14 @@ function toJSX(j: JSCodeshift, path: ASTPath<CallExpression>, pragmas: string[],
}
}

if (j.JSXIdentifier.check(tagClone)) {
removeDeclarationIfUnused(j, path, tagClone.name)
}

const openingElement = j.jsxOpeningElement(tag, attributes)
const closingElement = j.jsxClosingElement(tag)
const selfClosing = children.length === 0
if (selfClosing) openingElement.selfClosing = true
removeDeclarationIfUnused(j, path, tagClone.name)
return j.jsxElement(openingElement, selfClosing ? null : closingElement, children)
}

Expand Down

0 comments on commit d9f9d4e

Please sign in to comment.