Skip to content

Commit 26ecbf4

Browse files
yescalloprakshith-raviautofix-ci[bot]
authored
fix: allow non_snake_case and dead_code lints to run within component functions (#3198)
* fix: allow `non_snake_case` and `dead_code` lints to run within component functions * Fixed component type name * Update lib.rs * [autofix.ci] apply automated fixes --------- Co-authored-by: Rakshith Ravi <rakshith.ravi@gmx.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent b3885c7 commit 26ecbf4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

leptos_macro/src/component.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,10 @@ fn prop_to_doc(
13601360
}
13611361

13621362
pub fn unmodified_fn_name_from_fn_name(ident: &Ident) -> Ident {
1363-
Ident::new(&format!("__{ident}"), ident.span())
1363+
Ident::new(
1364+
&format!("__component_{}", ident.to_string().to_case(Snake)),
1365+
ident.span(),
1366+
)
13641367
}
13651368

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

leptos_macro/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,11 @@ fn component_macro(
683683
let parse_result = syn::parse::<component::Model>(s);
684684

685685
if let (Ok(ref mut unexpanded), Ok(model)) = (&mut dummy, parse_result) {
686-
let expanded = model.is_transparent(is_transparent).is_lazy(is_lazy).with_island(island).into_token_stream();
686+
let expanded = model
687+
.is_transparent(is_transparent)
688+
.is_lazy(is_lazy)
689+
.with_island(island)
690+
.into_token_stream();
687691
if !matches!(unexpanded.vis, Visibility::Public(_)) {
688692
unexpanded.vis = Visibility::Public(Pub {
689693
span: unexpanded.vis.span(),
@@ -696,7 +700,7 @@ fn component_macro(
696700
#expanded
697701

698702
#[doc(hidden)]
699-
#[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)]
703+
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes)]
700704
#unexpanded
701705
}
702706
} else {
@@ -705,7 +709,7 @@ fn component_macro(
705709
dummy.sig.ident = unmodified_fn_name_from_fn_name(&dummy.sig.ident);
706710
quote! {
707711
#[doc(hidden)]
708-
#[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)]
712+
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes)]
709713
#dummy
710714
}
711715
}

server_fn_macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ impl Parse for ServerFnBody {
15561556

15571557
impl ServerFnBody {
15581558
fn to_dummy_ident(&self) -> Ident {
1559-
Ident::new(&format!("__{}", self.ident), self.ident.span())
1559+
Ident::new(&format!("__server_{}", self.ident), self.ident.span())
15601560
}
15611561

15621562
fn to_dummy_output(&self) -> TokenStream2 {

0 commit comments

Comments
 (0)