Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Remove reliance on CamelCase component names #9

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions flake8_idom_hooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ def is_hook_def(node: ast.FunctionDef) -> bool:


def is_component_def(node: ast.FunctionDef) -> bool:
return is_component_function_name(node.name)


def is_component_function_name(name: str) -> bool:
return name[0].upper() == name[0] and "_" not in name
return any(
decorator.value.id == "idom" and decorator.attr == "component"
for decorator in node.decorator_list
)


def is_hook_function_name(name: str) -> bool:
return name.lstrip("_").startswith("use_")
return name.lstrip("_") in {
"use_state",
"use_effect",
"use_memo",
"use_reducer",
"use_callback",
"use_ref",
}