UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

113 lines (112 loc) 3.92 kB
import ts from "typescript"; import { AttributeInfo } from "../types/internalTypes"; /** * Utility functions for working with JSX elements in SEO analysis */ export declare class JsxUtils { /** * Gets the tag name of a JSX element */ static getTagName(node: ts.JsxElement | ts.JsxSelfClosingElement): string; /** * Gets the value of a JSX attribute */ static getAttribute(node: ts.JsxElement | ts.JsxSelfClosingElement, attributeName: string): string | null; /** * Gets all attributes from a JSX element */ static getAllAttributes(node: ts.JsxElement | ts.JsxSelfClosingElement): AttributeInfo[]; /** * Checks if a node is a Link component (Next.js, React Router, etc.) */ static isLinkComponent(node: ts.Node): boolean; /** * Checks if a node is an anchor tag */ static isAnchorTag(node: ts.Node): boolean; /** * Extracts link target from Link component or anchor */ static extractLinkTarget(node: ts.Node): string | null; /** * Checks if a node has accessible text (for SEO and a11y) */ static hasAccessibleText(node: ts.JsxElement | ts.JsxSelfClosingElement): boolean; /** * Checks if a node is an icon-only button (accessibility issue for SEO) */ static isIconOnlyButton(node: ts.JsxElement | ts.JsxSelfClosingElement): boolean; /** * Extracts text content from JSX elements */ static extractTextContent(node: ts.Node): string; /** * Detects Next.js Image component usage and optimization */ static isNextImageComponent(node: ts.Node): boolean; /** * Checks if image has performance-critical attributes */ static hasPerformanceOptimizedImage(node: ts.JsxElement | ts.JsxSelfClosingElement): { isOptimized: boolean; issues: string[]; hasLazyLoading: boolean; hasPriority: boolean; hasDimensions: boolean; }; /** * Detects lazy loading opportunities */ static getLazyLoadingInfo(node: ts.JsxElement | ts.JsxSelfClosingElement): { supportsLazyLoading: boolean; hasLazyLoading: boolean; method: "native" | "next-image" | "none"; recommendation: string | null; }; /** * Detects components that might benefit from lazy loading */ static isHeavyComponent(node: ts.JsxElement | ts.JsxSelfClosingElement): { isHeavy: boolean; reasons: string[]; complexity: "low" | "medium" | "high"; }; /** * Detects performance-impacting event handlers */ static hasPerformanceIssues(node: ts.JsxElement | ts.JsxSelfClosingElement): { hasIssues: boolean; issues: Array<{ type: "complex-handlers" | "too-many-handlers" | "inline-functions"; description: string; severity: "low" | "medium" | "high"; }>; }; /** * Detects third-party scripts and their performance impact */ static isThirdPartyScript(node: ts.JsxElement | ts.JsxSelfClosingElement): { isThirdParty: boolean; service: string | null; performanceImpact: "low" | "medium" | "high"; recommendations: string[]; }; /** * Detects preloading opportunities */ static shouldBePreloaded(node: ts.JsxElement | ts.JsxSelfClosingElement): { shouldPreload: boolean; resourceType: "image" | "font" | "script" | "style" | null; priority: "high" | "medium" | "low"; recommendation: string | null; }; /** * Analyzes Core Web Vitals impact of an element */ static analyzeCoreWebVitalsImpact(node: ts.JsxElement | ts.JsxSelfClosingElement): { lcpImpact: "none" | "low" | "medium" | "high"; clsImpact: "none" | "low" | "medium" | "high"; fidImpact: "none" | "low" | "medium" | "high"; recommendations: string[]; }; }