reactpy-flake8


Namereactpy-flake8 JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://github.com/reactive-python/reactpy-flake8
SummaryFlake8 plugin to enforce the rules of hooks for ReactPy
upload_time2023-04-30 04:05:14
maintainer
docs_urlNone
authorRyan Morshead
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `reactpy-flake8`

A Flake8 plugin that enforces the ["rules of hooks"](https://reactjs.org/docs/hooks-rules.html) for [ReactPy](https://github.com/reactive-python/reactpy).

The implementation is based on React's own ESLint [plugin for hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks).

# Install

```bash
pip install reactpy-flake8
```

# Developer Installation

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

Run the tests

```bash
nox -s test
```

# Errors

<table>
    <tr>
        <th>Code</th>
        <th>Message</th>
    </tr>
    <tr>
        <td>REACTPY100</td>
        <td>Hook is defined as a closure</td>
    </tr>
    <tr>
        <td>REACTPY101</td>
        <td>Hook was used outside component or hook definition</td>
    </tr>
    <tr>
        <td>REACTPY102</td>
        <td>Hook was used inside a conditional or loop statement</td>
    </tr>
    <tr>
        <td>REACTPY103</td>
        <td>Hook was used after an early return</td>
    </tr>
    <tr>
        <td>REACTPY200</td>
        <td>
            A hook's dependency is not destructured - dependencies should be refered to
            directly, not via an attribute or key of an object
        </td>
    </tr>
    <tr>
        <td>REACTPY201</td>
        <td>Hook dependency args should be a literal list, tuple or None</td>
    </tr>
    <tr>
        <td>REACTPY202</td>
        <td>
            Hook dependency is not specified
        </td>
    </tr>
</table>

# Options

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

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/reactive-python/reactpy-flake8",
    "name": "reactpy-flake8",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ryan Morshead",
    "author_email": "ryan.morshead@gmail.com",
    "download_url": "",
    "platform": "Linux",
    "description": "# `reactpy-flake8`\n\nA Flake8 plugin that enforces the [\"rules of hooks\"](https://reactjs.org/docs/hooks-rules.html) for [ReactPy](https://github.com/reactive-python/reactpy).\n\nThe implementation is based on React's own ESLint [plugin for hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks).\n\n# Install\n\n```bash\npip install reactpy-flake8\n```\n\n# Developer Installation\n\n```bash\npip install -r requirements.txt\npip install -e .\n```\n\nRun the tests\n\n```bash\nnox -s test\n```\n\n# Errors\n\n<table>\n    <tr>\n        <th>Code</th>\n        <th>Message</th>\n    </tr>\n    <tr>\n        <td>REACTPY100</td>\n        <td>Hook is defined as a closure</td>\n    </tr>\n    <tr>\n        <td>REACTPY101</td>\n        <td>Hook was used outside component or hook definition</td>\n    </tr>\n    <tr>\n        <td>REACTPY102</td>\n        <td>Hook was used inside a conditional or loop statement</td>\n    </tr>\n    <tr>\n        <td>REACTPY103</td>\n        <td>Hook was used after an early return</td>\n    </tr>\n    <tr>\n        <td>REACTPY200</td>\n        <td>\n            A hook's dependency is not destructured - dependencies should be refered to\n            directly, not via an attribute or key of an object\n        </td>\n    </tr>\n    <tr>\n        <td>REACTPY201</td>\n        <td>Hook dependency args should be a literal list, tuple or None</td>\n    </tr>\n    <tr>\n        <td>REACTPY202</td>\n        <td>\n            Hook dependency is not specified\n        </td>\n    </tr>\n</table>\n\n# Options\n\nAll options my be used as CLI flags where `_` characters are replaced with `-`. For\nexample, `exhaustive_hook_deps` would become `--exhaustive-hook-deps`.\n\n<table>\n    <tr>\n        <th>Option</th>\n        <th>Type</th>\n        <th>Default</th>\n        <th>Description</th>\n    </tr>\n    <tr>\n        <td><code>exhaustive_hook_deps</code></td>\n        <td>Boolean</td>\n        <td><code>False</code></td>\n        <td>Enable <code>REACTPY2**</code> errors (recommended)</td>\n    </tr>\n    <tr>\n        <td><code>component_decorator_pattern</code></td>\n        <td>Regex</td>\n        <td><code>^(component|[\\w\\.]+\\.component)$</code></td>\n        <td>\n            The pattern which should match the component decorators. Useful if\n            you import the <code>@component</code> decorator under an alias.\n        </td>\n    </tr>\n    <tr>\n        <td><code>hook_function_pattern</code></td>\n        <td>Regex</td>\n        <td><code>^_*use_\\w+$</code></td>\n        <td>\n            The pattern which should match the name of hook functions. Best used if you\n            have existing functions with <code>use_*</code> names that are not hooks.\n        </td>\n    </tr>\n</table>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Flake8 plugin to enforce the rules of hooks for ReactPy",
    "version": "0.7.0",
    "project_urls": {
        "Homepage": "https://github.com/reactive-python/reactpy-flake8"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09b8426598b4d7ed5b38aba93ef54d94816f5043647f94f1f340280b8b268c85",
                "md5": "d374bc0ee352380430ceb2b23d8ca9a6",
                "sha256": "cddd7f768577f5c4d9758b930fc7ed06c2fb512a7b9c49c3613db9da8977121b"
            },
            "downloads": -1,
            "filename": "reactpy_flake8-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d374bc0ee352380430ceb2b23d8ca9a6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9553,
            "upload_time": "2023-04-30T04:05:14",
            "upload_time_iso_8601": "2023-04-30T04:05:14.503305Z",
            "url": "https://files.pythonhosted.org/packages/09/b8/426598b4d7ed5b38aba93ef54d94816f5043647f94f1f340280b8b268c85/reactpy_flake8-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-30 04:05:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "reactive-python",
    "github_project": "reactpy-flake8",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "reactpy-flake8"
}
        
Elapsed time: 0.09164s