From b2efdc3383165be3a53adf48ec0c9b229d2e4f51 Mon Sep 17 00:00:00 2001 From: Scallop Ye Date: Tue, 5 Nov 2024 23:59:48 +0800 Subject: [PATCH] fix: allow `non_snake_case` and `dead_code` lints to run within component functions --- leptos_macro/src/component.rs | 5 ++++- leptos_macro/src/lib.rs | 9 ++++++--- server_fn_macro/src/lib.rs | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/leptos_macro/src/component.rs b/leptos_macro/src/component.rs index 37d6d42a74..3c2e3be5e6 100644 --- a/leptos_macro/src/component.rs +++ b/leptos_macro/src/component.rs @@ -1211,7 +1211,10 @@ fn prop_to_doc( } pub fn unmodified_fn_name_from_fn_name(ident: &Ident) -> Ident { - Ident::new(&format!("__{ident}"), ident.span()) + Ident::new( + &format!("__leptos_component_{}", ident.to_string().to_case(Snake)), + ident.span(), + ) } /// Converts all `impl Trait`s in a function signature to use generic params instead. diff --git a/leptos_macro/src/lib.rs b/leptos_macro/src/lib.rs index 5e592c40b7..646993499f 100644 --- a/leptos_macro/src/lib.rs +++ b/leptos_macro/src/lib.rs @@ -658,7 +658,10 @@ fn component_macro( let parse_result = syn::parse::(s); if let (Ok(ref mut unexpanded), Ok(model)) = (&mut dummy, parse_result) { - let expanded = model.is_transparent(is_transparent).with_island(island).into_token_stream(); + let expanded = model + .is_transparent(is_transparent) + .with_island(island) + .into_token_stream(); if !matches!(unexpanded.vis, Visibility::Public(_)) { unexpanded.vis = Visibility::Public(Pub { span: unexpanded.vis.span(), @@ -670,14 +673,14 @@ fn component_macro( #expanded #[doc(hidden)] - #[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)] + #[allow(clippy::too_many_arguments, clippy::needless_lifetimes)] #unexpanded } } else if let Ok(mut dummy) = dummy { dummy.sig.ident = unmodified_fn_name_from_fn_name(&dummy.sig.ident); quote! { #[doc(hidden)] - #[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)] + #[allow(clippy::too_many_arguments, clippy::needless_lifetimes)] #dummy } } else { diff --git a/server_fn_macro/src/lib.rs b/server_fn_macro/src/lib.rs index 1e80222a8e..d73023116e 100644 --- a/server_fn_macro/src/lib.rs +++ b/server_fn_macro/src/lib.rs @@ -1104,7 +1104,10 @@ impl Parse for ServerFnBody { impl ServerFnBody { fn to_dummy_ident(&self) -> Ident { - Ident::new(&format!("__{}", self.ident), self.ident.span()) + Ident::new( + &format!("__leptos_server_{}", self.ident), + self.ident.span(), + ) } fn to_dummy_output(&self) -> TokenStream2 {