Skip to content

Commit b2efdc3

Browse files
committed
fix: allow non_snake_case and dead_code lints to run within component functions
1 parent 8252655 commit b2efdc3

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

leptos_macro/src/component.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,10 @@ fn prop_to_doc(
12111211
}
12121212

12131213
pub fn unmodified_fn_name_from_fn_name(ident: &Ident) -> Ident {
1214-
Ident::new(&format!("__{ident}"), ident.span())
1214+
Ident::new(
1215+
&format!("__leptos_component_{}", ident.to_string().to_case(Snake)),
1216+
ident.span(),
1217+
)
12151218
}
12161219

12171220
/// Converts all `impl Trait`s in a function signature to use generic params instead.

leptos_macro/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,10 @@ fn component_macro(
658658
let parse_result = syn::parse::<component::Model>(s);
659659

660660
if let (Ok(ref mut unexpanded), Ok(model)) = (&mut dummy, parse_result) {
661-
let expanded = model.is_transparent(is_transparent).with_island(island).into_token_stream();
661+
let expanded = model
662+
.is_transparent(is_transparent)
663+
.with_island(island)
664+
.into_token_stream();
662665
if !matches!(unexpanded.vis, Visibility::Public(_)) {
663666
unexpanded.vis = Visibility::Public(Pub {
664667
span: unexpanded.vis.span(),
@@ -670,14 +673,14 @@ fn component_macro(
670673
#expanded
671674

672675
#[doc(hidden)]
673-
#[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)]
676+
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes)]
674677
#unexpanded
675678
}
676679
} else if let Ok(mut dummy) = dummy {
677680
dummy.sig.ident = unmodified_fn_name_from_fn_name(&dummy.sig.ident);
678681
quote! {
679682
#[doc(hidden)]
680-
#[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)]
683+
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes)]
681684
#dummy
682685
}
683686
} else {

server_fn_macro/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,10 @@ impl Parse for ServerFnBody {
11041104

11051105
impl ServerFnBody {
11061106
fn to_dummy_ident(&self) -> Ident {
1107-
Ident::new(&format!("__{}", self.ident), self.ident.span())
1107+
Ident::new(
1108+
&format!("__leptos_server_{}", self.ident),
1109+
self.ident.span(),
1110+
)
11081111
}
11091112

11101113
fn to_dummy_output(&self) -> TokenStream2 {

0 commit comments

Comments
 (0)