Coder Social home page Coder Social logo

reactpy-flake8's Introduction

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
RPY100 Hook is defined as a closure
RPY101 Hook was used outside component or hook definition
RPY102 Hook was used inside a conditional or loop statement
RPY103 Hook was used after an early return
RPY200 A hook's dependency is not destructured - dependencies should be refered to directly, not via an attribute or key of an object
RPY201 Hook dependency args should be a literal list, tuple or None
RPY202 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.