Skip to main content

flake8-idom-hooks

A Flake8 plugin that enforces the "rules of hooks" for IDOM.

The implementation is based on React's own ESLint plugin for hooks.

Install

pip install flake8-idom-hooks

Developer Installation

pip install -r requirements.txt
pip install -e .

Run the tests

tox

Errors

Code Message
ROH100 Hook is defined as a closure
ROH101 Hook was used outside component or hook definition
ROH102 Hook was used inside a conditional or loop statement
ROH103 Hook was used after an early return
ROH200 A hook's dependency is not destructured - dependencies should be refered to directly, not via an attribute or key of an object
ROH201 Hook dependency args should be a literal list, tuple or None
ROH202 Hook dependency is not specified

Options

All options my be used as CLI flags where _ characters are replaced with -. For example, exhaustive_hook_deps would become --exhaustive-hook-deps.

Option Type Default Description
exhaustive_hook_deps Boolean False Enable ROH2** errors (recommended)
component_decorator_pattern Regex ^(component|[\w\.]+\.component)$ The pattern which should match the component decorators. Useful if you import the @component decorator under an alias.
hook_function_pattern Regex ^_*use_\w+$ The pattern which should match the name of hook functions. Best used if you have existing functions with use_* names that are not hooks.

Metadata

Release files for flake8-idom-hooks 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for flake8-idom-hooks 0.6.4
File Interpreter ABI Platform
flake8_idom_hooks-0.6.4-py3-none-any.whl Python 3 none any Details

Release files / flake8_idom_hooks-0.6.4-py3-none-any.whl

Download URL flake8_idom_hooks-0.6.4-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebd8e11c700e7e74c60c5f2a2de9fd68158b1e559ac617b5e2536ad58699bfd8
BLAKE2b-256 checksum
How to use checksums
3b8f58d9ef690023285537d9f9855585d334dee84e08c8b55e441ef3942721d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release history Release notifications | RSS feed

This release

0.6.4 This release

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page