From 61c6c0b21188b5dfde5d72eaa08c9e37ad9d8d43 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 | 4 ++-- server_fn_macro/src/lib.rs | 5 ++++- 3 files changed, 10 insertions(+), 4 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..3fce009ddd 100644 --- a/leptos_macro/src/lib.rs +++ b/leptos_macro/src/lib.rs @@ -670,14 +670,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 {