systomic

Enforce skeleton

When a component renders nothing while it loads, the content pops in afterwards and pushes everything below it. A skeleton with the final size keeps the layout still.

  • RuleIn recommended.json: breaking it breaks the design-system contract.
  • WarningShows in the editor and in CI output, but doesn't fail the run (unless you pass --deny-warnings).

See the difference

Before

Account

Notifications
LanguageEnglish
{data && <span>{data.name}</span>}
After

Account

Notifications
LanguageEnglish
{data ? <span>{data.name}</span> : <Skeleton />}

What doesn't work

3 findings

What works

No findings

Details

Content that is still loading renders a skeleton with its final size, not nothing. When a component renders nothing while loading, the content pops in afterwards and pushes everything around it: a layout shift.

data renders nothing while loading, then the content pops in and shifts the layout. Render a skeleton with the final size while loading.

How it decides

The rule evaluates each condition as it would be while loading:

  • loading flags are true: isLoading, isPending, isFetching, loading, isUserLoading, query.isPending, … (loadingPattern),
  • data from a query hook is undefined: data (also renamed, { data: user }) from useQuery, useInfiniteQuery, useSWR, tRPC api.x.useQuery(), useFetch…, useLiveQuery, query.data, and Convex-style const tasks = useQuery(…), plus hooks in hooks,
  • status is "pending", and query.isSuccess is false; error state (query.isError, error, failureReason, status === "error", …) is unknown, as it is also falsy once the data is loaded.

Anything else is unknown. Only when the result is certain, and the branch shown while loading renders nothing, is it reported:

  • {data && <Content />}, {!isLoading && <Content />}, {data?.user && <Avatar />}, {data && isAdmin && <Badge />},
  • {isLoading ? null : <Content />}, {data ? <Content /> : undefined}, {status === "pending" ? null : …}, {tasks !== undefined && …},
  • early returns in components: if (!data) return null, if (isPending) return;,
  • <Suspense> without a fallback, or with fallback={null}.

Not reported

  • Loading indicators and skeletons: {isLoading && <Spinner />}, isLoading ? <Skeleton /> : ….
  • Conditions that don’t depend on loading: optional content (user.bio ? … : null), errors ({query.isError && <ErrorMessage />}), local state, props (if (!user) return null).
  • Empty states: {data?.length === 0 && <EmptyState />} only shows after loading, by design.
  • Suspense hooks (useSuspenseQuery), which always have data.
  • Overlays ({data && <Dialog />}): they don’t shift the layout. See no-conditional-overlay.
Option Default
hooks []: extra hooks whose result (or its data) is undefined while loading, e.g. ["useProject"]
loadingPattern regex for loading flags, replaces the default
ignore []: file globs relative to the nearest package.json; see monorepos
Esc