507 lines · 17.7 KB
/**
 * Custom oxlint rules.
 *
 * Each rule preserves severity and detection semantics of the original
 * hand-written checks. ESLint-compatible plugin format, loaded via `jsPlugins`
 * in `.oxlintrc.json`.
 */

/** @typedef {import("eslint").Rule.RuleModule} RuleModule */

const QUERY_HOOKS = new Set(["useQuery", "useMutation", "useSuspenseQuery", "useInfiniteQuery"]);
const BROWSER_GLOBALS = new Set(["window", "document", "navigator", "localStorage", "sessionStorage"]);

// React client-only APIs whose mere use requires a client component.
const CLIENT_REACT_APIS = new Set(["createContext", "useContext"]);

// Packages whose components/utilities require rendering in a client component.
// A file that imports from any of these is treated as legitimately "use client".
const CLIENT_ONLY_IMPORTS = new Set([
  "recharts",
  "framer-motion",
  "motion",
  "motion/react",
  "sonner",
  "vaul",
  "cmdk",
  "next-themes",
  "react-resizable-panels",
  "react-scroll-parallax",
  "@react-three/drei",
  "@react-three/fiber",
  "three",
  "maplibre-gl",
  "react-map-gl",
  "pmtiles",
  "streamdown",
  "zustand",
  "embla-carousel-react",
  "react-day-picker",
  "react-hook-form",