Flake8 plugin to enforce the rules of hooks for ReactPy
Project description
reactpy-flake8
A Flake8 plugin that enforces the "rules of hooks" for ReactPy.
The implementation is based on React's own ESLint plugin for hooks.
Install
pip install reactpy-flake8
Developer Installation
pip install -r requirements.txt
pip install -e .
Run the tests
nox -s test
Errors
Code | Message |
---|---|
REACTPY100 | Hook is defined as a closure |
REACTPY101 | Hook was used outside component or hook definition |
REACTPY102 | Hook was used inside a conditional or loop statement |
REACTPY103 | Hook was used after an early return |
REACTPY200 | A hook's dependency is not destructured - dependencies should be refered to directly, not via an attribute or key of an object |
REACTPY201 | Hook dependency args should be a literal list, tuple or None |
REACTPY202 | 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 REACTPY2** 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.
|
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file reactpy_flake8-0.6.5-py3-none-any.whl
.
File metadata
- Download URL: reactpy_flake8-0.6.5-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b73a6658ed5c4e03e576a80b5d4f9a542db9a323aaa0de4916403be58aebea2 |
|
MD5 | 62b9690260f8668e36cd383c21a5d0e7 |
|
BLAKE2b-256 | e8595629c8cecd5dcbd11f91d830d09f1e40d517fe60b8d508dcead179b4e383 |