MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / updateClassName

Function updateClassName

packages/cli/src/transform.ts:535–553  ·  view source on GitHub ↗
(
  filePath: string,
  lineNumber: number,
  columnNumber: number,
  updates: ClassNameUpdate[]
)

Source from the content-addressed store, hash-verified

533}
534
535export function updateClassName(
536 filePath: string,
537 lineNumber: number,
538 columnNumber: number,
539 updates: ClassNameUpdate[]
540): string {
541 const source = fs.readFileSync(filePath, "utf-8");
542 const { j, root, quoteStyle } = parseSource(source, filePath);
543
544 const target = findJSXElementAt(j, root, lineNumber, columnNumber);
545 if (!target) {
546 throw new Error(
547 `No JSX element found at ${lineNumber}:${columnNumber}`
548 );
549 }
550
551 mutateClassName(j, target, updates);
552 return root.toSource({ quote: quoteStyle });
553}
554
555// ── updateTextContent ────────────────────────────────────────────────────
556

Callers 1

Calls 3

parseSourceFunction · 0.85
findJSXElementAtFunction · 0.85
mutateClassNameFunction · 0.85

Tested by

no test coverage detected