package react-rules-of-hooks-ppx

  1. Overview
  2. Docs

Changes

1.1.0

  • [FEAT] Disable order of hooks attribute [@disable_order_of_hooks]
  • [CHORE] Add mlx as :with-test and :with-dev-setup (previously only :with-dev-setup)
  • [FIX] Add support for snake_case hooks (use_state, use_effect, use_custom_hook)
  • [FIX] SVG <use> element no longer incorrectly flagged as a hook (JSX elements excluded from hook detection)
  • [FIX] False positive when multiple hooks are defined
  • [FIX] Hooks name can be "use"
  • [FIX] Fix static deps scope leaking between components (useState setters, useReducer dispatchers, useRef results now properly scoped per component)
  • [FIX] JSX context reset bug where multiple hooks in the same JSX element weren't all flagged as violations
  • [FEAT] Add Pexp_letop support for monadic let+/and+ syntax in exhaustive deps checking
  • [TEST] Add test cases inspired by React's eslint-plugin-react-hooks
  • [FEAT] Add REACT_HOOKS_PPX_TIMING env var to print timing diagnostics
  • [FIX] Use Set for O(log n) lookups, single-pass AST analysis, caching
  • [FIX] Simplify diff function
  • [FIX] Replace List.length > 0 with <> []
  • [FIX] Optimize find_duplicates to deduplicate during traversal

1.0.0

  • [FEAT] Detect hooks called conditionally, in loops, or in nested functions
  • [FEAT] Detect hooks called outside of [@react.component] functions or custom hooks
  • [FEAT] Check exhaustive dependencies in useEffect, useMemo, useCallback, useLayoutEffect, and useInsertionEffect
  • [FEAT] Disable order of hooks check globally with -order-of-hooks ppx flag
  • [FEAT] Disable exhaustive deps check globally with -exhaustive-deps ppx flag
  • [FEAT] Suppress exhaustive deps warning locally with [@disable_exhaustive_deps] attribute
  • [FEAT] -corrections flag to generate .ppx-corrected files with suggested fixes for missing dependencies
  • [FIX] Improve -corrections according to the reason-react interface