Файли
openidea/src/features/vcs/CommitMessageContent.tsx
T
Akbar Husain aa1b6c1ce0 perf(lint): fix React performance lint violations (#5503)
Clears the React-specific violations reported by oxlint's `perf` category: 123 array-index keys, 28 constructed context values and 6 object/array default props. Keys now use a stable data id where one exists, and the index with a short documented suppression where position is the real identity (editable rows, streams, repeated data). Context values are memoized or hoisted, and default literals are module-level constants. Enabling the `perf` category itself is handled separately; this PR only fixes the violations.

Co-authored-by: akbar1214 <[email protected]>
2026-11-24 08:06:54 +08:00

46 рядки
1.5 KiB
TypeScript

import type { Commit } from "@/bindings";
import type { ReactNode } from "react";
import { fontWeightOf } from "@/platform/editorSettings";
import { resolveMonoFont } from "@/platform/fonts";
import { tx } from "@/platform/i18n";
import { useProject } from "@/platform/project";
import styles from "./GitLog.module.css";
const identityText = (text: string): ReactNode => text;
export function CommitMessageContent({
commit,
message,
compact = false,
renderText = identityText,
revision = commit.shortId,
}: {
commit: Commit;
message: string;
compact?: boolean;
renderText?: (text: string) => ReactNode;
revision?: ReactNode;
}) {
const editor = useProject((s) => s.settings?.editor);
const { family, size } = resolveMonoFont(undefined, editor);
const [subject = "", ...bodyLines] = message.trimEnd().split("\n");
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
return (
<>
<div
className={styles.messageText}
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
>
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
{renderText(subject)}
</div>
{body && <div className={styles.fullMessage}>{renderText(body)}</div>}
</div>
<div className={styles.meta}>
{revision} {commit.author} &lt;{commit.email}&gt;
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
</div>
</>
);
}