react-doctor/no-moment
Replace with `import { format } from 'date-fns'` (tree-shakeable) or `import dayjs from 'dayjs'` (2kb)
- Category: Bundle Size
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm an ImportDeclaration whose source is exactly "moment" — roughly 300kb of locales plus a mutable Moment object that defeats tree-shaking. The rule does not flag moment-timezone, moment-duration-format, or dayjs/plugin/moment; it targets only the core package import.
Fix prompt
Use this once validation confirms the diagnostic is real.
Migrate to a tree-shakeable alternative — date-fns for functional, immutable APIs (import { format } from "date-fns") or dayjs (~2kb gzipped) for a near-drop-in moment-compatible chainable API. Both expose locale and timezone packages on demand. See https://momentjs.com/docs/#/-project-status/
Related rules
More Bundle Size rules from the rules reference:
react-doctor/no-undeferred-third-party: Use `next/script` with `strategy="lazyOnload"` or add the `defer` attributereact-doctor/prefer-dynamic-import: Use `const Component = dynamic(() => import('library'), { ssr: false })` from next/dynamic or React.lazy()react-doctor/use-lazy-motion: Use `import { LazyMotion, m } from "framer-motion"` with `domAnimation` features — saves ~30kbreact-doctor/no-barrel-import: Import from the direct path: `import { Button } from './components/Button'` instead of `./components`react-doctor/no-dynamic-import-path: Use a string-literal path: `import('./feature/heavy.js')` so the bundler can split this chunk