package react-rules-of-hooks-ppx

  1. Overview
  2. Docs
This ppx validates the rules of React hooks in reason-react components

Install

dune-project
 Dependency

Authors

Maintainers

Sources

react-rules-of-hooks-ppx-1.2.0.tbz
sha256=ee569398e9fde0d18c694c1a13be0bcdbbb0df7ffb4d2844d908c645e1c20b3c
sha512=f8e178d0be3e5b39cf070e2bd35c838c563947829f6e8a4b15bf8ba59a2b324918d169c52e5a4651d0c84d883e404d430502d893b16a6a219789c95b1a6bcd5a

doc/CHANGES.html

Changes

1.2.0

  • [FEAT] Support use + numbers as a valid hook name
  • [FIX] Outer scope bindings (module-level values and functions) no longer trigger missing dependency warnings in exhaustive deps checks

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