Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow non_snake_case and dead_code lints to run within component functions #3198

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion leptos_macro/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
rakshith-ravi marked this conversation as resolved.
Show resolved Hide resolved
&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.
Expand Down
9 changes: 6 additions & 3 deletions leptos_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,10 @@ fn component_macro(
let parse_result = syn::parse::<component::Model>(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(),
Expand All @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion server_fn_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading