Skip to content

v0.1.0

Choose a tag to compare

@sathvikc sathvikc released this 30 May 22:34
· 5 commits to main since this release

eslint-plugin-strict-hooks

πŸš€ v0.1.0 – Initial Release

Adds a new ESLint rule to enforce meaningful comments when disabling react-hooks/exhaustive-deps.

βœ… New Rule: require-exhaustive-deps-comment

This rule ensures developers explicitly mention which dependencies are intentionally omitted from the dependency array when disabling react-hooks/exhaustive-deps.

πŸ”§ Valid Example

useEffect(() => {
  fetchData();
}, []); // eslint-disable-line react-hooks/exhaustive-deps -- fetchData: memoized

❌ Invalid Example

useEffect(() => {
  fetchData();
}, []); // eslint-disable-line react-hooks/exhaustive-deps

🎯 What it Detects

  • βœ… Dependencies used but not mentioned in the disable comment
  • βœ… Stale entries: variables mentioned in the comment that are no longer used
  • βœ… Empty -- comment when dependencies are omitted

πŸ”§ Configurable Options

rules: {
  "strict-hooks/require-exhaustive-deps-comment": ["warn", {
    enabledHooks: ["useEffect", "useMemo", "useCallback"],
    requireCommentPerDependency: true,
    disabledHooks: []
  }]
}

🧠 Limitations

  • No autofix (yet)
  • Does not support destructured/memoized property tracking
  • Does not resolve shadowed identifiers

Full Changelog: https://github.com/sathvikc/eslint-plugin-strict-hooks/commits/v0.1.0