mirror of
https://github.com/millionco/react-doctor.git
synced 2026-09-14 20:00:24 +08:00
24 lines
697 B
Rust
24 lines
697 B
Rust
fn is_top_level_page_copy_root(
|
|
element: &oxc_ast::ast::JSXElement,
|
|
node: &crate::AstNode,
|
|
ctx: &crate::context::LintContext,
|
|
) -> bool {
|
|
if !is_page_copy_root(element) {
|
|
return false;
|
|
}
|
|
!ctx.nodes().ancestors(node.id()).any(|ancestor| {
|
|
matches!(
|
|
ancestor.kind(),
|
|
oxc_ast::AstKind::JSXElement(ancestor_element) if is_page_copy_root(ancestor_element)
|
|
)
|
|
})
|
|
}
|
|
|
|
fn is_page_copy_root(element: &oxc_ast::ast::JSXElement) -> bool {
|
|
matches!(
|
|
&element.opening_element.name,
|
|
oxc_ast::ast::JSXElementName::Identifier(identifier)
|
|
if identifier.name == "article" || identifier.name == "main"
|
|
)
|
|
}
|