fix: react-doctor async-defer-await 10→0 (move await below guards), rerender-memo-with-default-value 13→0 (module-scope EMPTY_* defaults)

This commit is contained in:
Nora
2026-06-26 06:42:08 -06:00
parent 38bd3fcbc7
commit 3d5988afd0
18 changed files with 69 additions and 25 deletions
+11 -1
View File
@@ -56,6 +56,14 @@ type Order = {
order_items?: OrderItem[];
};
type Product = {
id: string;
name: string;
price: number;
type?: string | null;
active?: boolean;
};
type Stop = {
id: string;
city: string;
@@ -91,10 +99,12 @@ const ChevronDownIcon = () => <ChevronDown className="h-4 w-4" strokeWidth={2} /
const ChevronLeftIcon = () => <ChevronLeft className="h-4 w-4" strokeWidth={2} />;
const ChevronRightIcon = () => <ChevronRight className="h-4 w-4" strokeWidth={2} />;
const EMPTY_PRODUCTS: Product[] = [];
export default function AdminOrdersPanel({
initialOrders,
initialStops,
initialProducts = [],
initialProducts = EMPTY_PRODUCTS,
brandId,
}: AdminOrdersPanelProps) {
const { success: showSuccess, error: showError } = useToast();
+3 -1
View File
@@ -20,6 +20,8 @@ type Props = {
isPlatformAdmin?: boolean;
};
const EMPTY_BRANDS: { id: string; name: string }[] = [];
export default function BrandSettingsForm(props: Props) {
// Non-platform-admin case: the brand never changes, so we can pass props
// straight through (key forces the body to remount if the outer ever
@@ -41,7 +43,7 @@ function PlatformAdminBrandSettingsForm({
settings: _initialSettings,
brandId: initialBrandId,
brandName: initialBrandName,
brands = [],
brands = EMPTY_BRANDS,
isPlatformAdmin: _isPlatformAdmin,
}: Props) {
// Use lazy initializers so the lint's static "useState(prop)" check
+7 -3
View File
@@ -86,6 +86,10 @@ const ChartIcon = () => (
</svg>
);
const EMPTY_CONTACTS: Contact[] = [];
const EMPTY_SEGMENTS: Segment[] = [];
const EMPTY_ANALYTICS: CampaignAnalytics[] = [];
export default function CommunicationsPage({
campaigns,
templates,
@@ -93,10 +97,10 @@ export default function CommunicationsPage({
editCampaign,
editMode,
editTemplate,
initialContacts = [],
initialContacts = EMPTY_CONTACTS,
initialContactTotal = 0,
initialSegments = [],
initialAnalytics = [],
initialSegments = EMPTY_SEGMENTS,
initialAnalytics = EMPTY_ANALYTICS,
editCampaignId,
initialTab,
}: {
+3 -1
View File
@@ -41,7 +41,9 @@ type Props = {
lockBrand?: boolean;
};
export default function NewProductForm({ defaultBrandId = "", brands = [], lockBrand = false }: Props) {
const EMPTY_BRANDS: { id: string; name: string }[] = [];
export default function NewProductForm({ defaultBrandId = "", brands = EMPTY_BRANDS, lockBrand = false }: Props) {
const router = useRouter();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
+3 -1
View File
@@ -33,7 +33,9 @@ interface ValidationErrors {
squareLocationId?: string;
}
export default function PaymentSettingsForm({ settings, brandId, brands = [], isPlatformAdmin = false }: Props) {
const EMPTY_BRANDS: { id: string; name: string }[] = [];
export default function PaymentSettingsForm({ settings, brandId, brands = EMPTY_BRANDS, isPlatformAdmin = false }: Props) {
// Use lazy initializers so the lint's static "useState(prop)" check does
// not fire; the values are computed on first render and then mutated
// locally as the user edits. When the parent passes a new prop, the
+3 -1
View File
@@ -79,13 +79,15 @@ const TYPE_OPTIONS: Array<{
},
];
const EMPTY_BRANDS: { id: string; name: string }[] = [];
export default function ProductFormModal({
open,
mode,
onClose,
onSubmit,
initial,
brands = [],
brands = EMPTY_BRANDS,
lockBrand = false,
lockedBrandId = "",
initialImageUrl = null,
+3 -1
View File
@@ -64,10 +64,12 @@ async function resizeImage(file: File, maxWidth: number): Promise<ArrayBuffer> {
});
}
const EMPTY_BRANDS: { id: string; name: string }[] = [];
export default function ProductsClient({
products,
brandId,
brands = [],
brands = EMPTY_BRANDS,
isPlatformAdmin = false,
}: {
products: Product[];
@@ -31,6 +31,8 @@ interface ValidationErrors {
fedexApiSecret?: string;
}
const EMPTY_BRANDS: { id: string; name: string }[] = [];
export default function ShippingSettingsForm(props: Props) {
// Non-platform-admin case: brand is fixed, just pass props through.
// The body's `key` forces a remount if the brand id ever changes.
@@ -49,7 +51,7 @@ export default function ShippingSettingsForm(props: Props) {
function PlatformAdminShippingSettingsForm({
settings: _initialSettings,
brandId: initialBrandId,
brands = [],
brands = EMPTY_BRANDS,
isPlatformAdmin: _isPlatformAdmin,
}: Props) {
// Lazy initializers so the lint's static "useState(prop)" check does not fire.
@@ -211,10 +211,12 @@ function CheckIcon({ className }: { className?: string }) {
);
}
const EMPTY_ORDERS: LotOrder[] = [];
export default function LotDetailPanel({
lot,
brandId,
orders = [],
orders = EMPTY_ORDERS,
}: {
lot: LotDetail;
brandId: string;