@ionic/angular-standalone-codemods
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -682,47 +682,49 @@ #!/usr/bin/env node | ||
if (node.name === "ion-icon") { | ||
const staticNameAttribute = node.attributes.find( | ||
(a) => a.name === "name" || a.name === "icon" | ||
); | ||
if (staticNameAttribute) { | ||
const iconName = staticNameAttribute.value; | ||
if (!ionIcons.includes(iconName)) { | ||
ionIcons.push(iconName); | ||
} | ||
} else { | ||
const boundNameAttribute = node.inputs.find( | ||
(a) => a.name === "name" || a.name === "icon" | ||
for (const attribute of ["name", "icon", "ios", "md"]) { | ||
const staticNameAttribute = node.attributes.find( | ||
(a) => a.name === attribute | ||
); | ||
if (boundNameAttribute) { | ||
const skippedIcon = node.sourceSpan.toString(); | ||
const iconNameRegex = /{{\s*'([^']+)'\s*}}/; | ||
const iconNameMatch = skippedIcon.match(iconNameRegex); | ||
const deepGetIconConditional = (ast2, icons) => { | ||
if (ast2.trueExp.type === "LiteralPrimitive") { | ||
if (!ionIcons.includes(ast2.trueExp.value)) { | ||
ionIcons.push(ast2.trueExp.value); | ||
if (staticNameAttribute) { | ||
const iconName = staticNameAttribute.value; | ||
if (!ionIcons.includes(iconName)) { | ||
ionIcons.push(iconName); | ||
} | ||
} else { | ||
const boundNameAttribute = node.inputs.find( | ||
(a) => a.name === attribute | ||
); | ||
if (boundNameAttribute) { | ||
const skippedIcon = node.sourceSpan.toString(); | ||
const iconNameRegex = /{{\s*'([^']+)'\s*}}/; | ||
const iconNameMatch = skippedIcon.match(iconNameRegex); | ||
const deepGetIconConditional = (ast2, icons) => { | ||
if (ast2.trueExp.type === "LiteralPrimitive") { | ||
if (!ionIcons.includes(ast2.trueExp.value)) { | ||
ionIcons.push(ast2.trueExp.value); | ||
} | ||
} else if (ast2.trueExp.type === "Conditional") { | ||
deepGetIconConditional(ast2.trueExp, icons); | ||
} else { | ||
skippedIconsHtml.push(skippedIcon); | ||
} | ||
} else if (ast2.trueExp.type === "Conditional") { | ||
deepGetIconConditional(ast2.trueExp, icons); | ||
} else { | ||
skippedIconsHtml.push(skippedIcon); | ||
} | ||
if (ast2.falseExp.type === "LiteralPrimitive") { | ||
if (!ionIcons.includes(ast2.falseExp.value)) { | ||
ionIcons.push(ast2.falseExp.value); | ||
if (ast2.falseExp.type === "LiteralPrimitive") { | ||
if (!ionIcons.includes(ast2.falseExp.value)) { | ||
ionIcons.push(ast2.falseExp.value); | ||
} | ||
} else if (ast2.falseExp.type === "Conditional") { | ||
deepGetIconConditional(ast2.falseExp, icons); | ||
} else { | ||
skippedIconsHtml.push(skippedIcon); | ||
} | ||
} else if (ast2.falseExp.type === "Conditional") { | ||
deepGetIconConditional(ast2.falseExp, icons); | ||
return icons; | ||
}; | ||
if (iconNameMatch) { | ||
if (!ionIcons.includes(iconNameMatch[1])) { | ||
ionIcons.push(iconNameMatch[1]); | ||
} | ||
} else if (boundNameAttribute.value.ast.type === "Conditional") { | ||
deepGetIconConditional(boundNameAttribute.value.ast, ionIcons); | ||
} else { | ||
skippedIconsHtml.push(skippedIcon); | ||
} | ||
return icons; | ||
}; | ||
if (iconNameMatch) { | ||
if (!ionIcons.includes(iconNameMatch[1])) { | ||
ionIcons.push(iconNameMatch[1]); | ||
} | ||
} else if (boundNameAttribute.value.ast.type === "Conditional") { | ||
deepGetIconConditional(boundNameAttribute.value.ast, ionIcons); | ||
} else { | ||
skippedIconsHtml.push(skippedIcon); | ||
} | ||
@@ -729,0 +731,0 @@ } |
{ | ||
"name": "@ionic/angular-standalone-codemods", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "@angular-eslint/template-parser": "^17.1.0", |
Sorry, the diff of this file is not supported yet
89120
2258