Skip to content

Commit 8e5abf5

Browse files
knuttiesclaudeayushjain17
authored
refactor(frontend): Convert all Leptos component function names to PascalCase (#822)
* refactor(frontend): Convert all Leptos component function names to PascalCase - Renamed 121 component functions from snake_case to PascalCase - Improves consistency between function definitions and component usage in JSX - Makes component functions easier to search and identify - All component definitions now match their usage in view! macros - Build verified successfully with no errors Examples of changes: - experiment_list -> ExperimentList - button -> Button - side_nav -> SideNav - experiment_form -> ExperimentForm * feat(lint): Add PascalCase linter for Leptos components - Created scripts/check_component_names.sh to enforce PascalCase naming - Integrated linter into `make check` target - Automatically runs in CI via existing check workflow - Prevents regression to snake_case component names The linter scans all Leptos component functions and ensures they use PascalCase naming convention for consistency with JSX usage. Also fixed makefile syntax issues: - Corrected .PHONY declaration format - Fixed tab/space inconsistency in ifeq block * fix(lint): Address coderabbit review comments This commit addresses all coderabbit review feedback: 1. **Fixed sed portability** (scripts/check_component_names.sh:30) - Changed `-r` flag to `-E` for BSD/macOS compatibility - Extended regex now works on both GNU sed and BSD sed 2. **Renamed all private components to PascalCase** (31 components) - webhook_info -> WebhookInfo (pages/webhook.rs:26) - info_section -> InfoSection (components/info_modal.rs:4) - experiment_group_info -> ExperimentGroupInfo (pages/experiment_groups.rs:6) - variable_info -> VariableInfo (pages/variable.rs:20) - option and context_options -> Option, ContextOptions (components/context_card.rs:21,38) - experiment_info and action components (components/experiment.rs:29,148,181,222,237,242) - And 20+ other private components across multiple files 3. **Enhanced linter to check private components** - Now enforces PascalCase for both public and private components - Fixed false positives on nested helper functions - Only matches top-level component function definitions All changes maintain consistency between component definitions and their usage in JSX view macros. Build verified successfully. Resolves all 7 coderabbit nitpick comments on the PR. * fix: script for checking function names and add auto fix support --------- Co-authored-by: Claude <[email protected]> Co-authored-by: [email protected] <[email protected]>
1 parent 2d99a0a commit 8e5abf5

File tree

91 files changed

+321
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+321
-193
lines changed

crates/frontend/src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::pages::{
3030
use crate::types::Envs;
3131

3232
#[component]
33-
pub fn app(app_envs: Envs) -> impl IntoView {
33+
pub fn App(app_envs: Envs) -> impl IntoView {
3434
// Provides context that manages stylesheets, titles, meta tags, etc.
3535
provide_meta_context();
3636
let service_prefix = app_envs.service_prefix;

crates/frontend/src/bindings/sortable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl SortableConfig {
116116
/// use leptos::*;
117117
///
118118
/// #[component]
119-
/// fn demo_component() -> impl IntoView {
119+
/// fn DemoComponent() -> impl IntoView {
120120
/// Effect::new(move |_| {
121121
/// let window = web_sys::window().unwrap();
122122
/// let document = window.document().unwrap();

crates/frontend/src/components/alert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl AlertType {
5757
}
5858

5959
#[component]
60-
pub fn alert(alert: Alert) -> impl IntoView {
60+
pub fn Alert(alert: Alert) -> impl IntoView {
6161
let outer_div_class =
6262
format!("alert max-w-[90vw] {}", alert.alert_type.to_css_class());
6363
let content_icon = alert.alert_type.to_icon_class();

crates/frontend/src/components/badge.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::components::form::label::Label;
99
use super::dropdown::utils::DropdownOption;
1010

1111
#[component]
12-
pub fn badge<T>(
12+
pub fn Badge<T>(
1313
#[prop(into)] options: Signal<Vec<T>>,
1414
#[prop(into, optional)] handle_remove: Option<Callback<T, ()>>,
1515
#[prop(into, default = String::new())] class: String,
@@ -57,7 +57,7 @@ where
5757
}
5858

5959
#[component]
60-
pub fn gray_pill<T: Display + Clone + 'static>(
60+
pub fn GrayPill<T: Display + Clone + 'static>(
6161
#[prop(into)] data: T,
6262
#[prop(optional_no_strip)] renderer: Option<Callback<T, View>>,
6363
#[prop(into, default = String::new())] icon_class: String,
@@ -87,7 +87,7 @@ pub fn gray_pill<T: Display + Clone + 'static>(
8787
}
8888

8989
#[component]
90-
pub fn list_pills<T>(
90+
pub fn ListPills<T>(
9191
#[prop(into)] label: String,
9292
#[prop(into)] items: Vec<T>,
9393
#[prop(optional)] pill_renderer: Option<Callback<T, View>>,
@@ -126,7 +126,7 @@ where
126126
}
127127

128128
#[component]
129-
pub fn glassy_pills<T: IntoEnumIterator + Display + Eq + Hash + Copy + 'static>(
129+
pub fn GlassyPills<T: IntoEnumIterator + Display + Eq + Hash + Copy + 'static>(
130130
#[prop(into)] selected: Signal<Vec<T>>,
131131
#[prop(into)] title: String,
132132
#[prop(into)] on_click: Callback<Vec<T>, ()>,

crates/frontend/src/components/button.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub enum ButtonStyle {
1010
}
1111

1212
#[component]
13-
pub fn button(
13+
pub fn Button(
1414
#[prop(into)] text: String,
1515
#[prop(into)] on_click: Callback<MouseEvent, ()>,
1616
#[prop(into, default = String::new())] class: String,
@@ -61,7 +61,7 @@ pub fn button(
6161
}
6262

6363
#[component]
64-
pub fn button_anchor(
64+
pub fn ButtonAnchor(
6565
#[prop(into)] text: String,
6666
#[prop(into)] href: String,
6767
#[prop(into, default = String::new())] class: String,

crates/frontend/src/components/change_form.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use leptos::*;
33
use crate::components::form::label::Label;
44

55
#[component]
6-
pub fn change_form(
6+
pub fn ChangeForm(
77
#[prop(into)] title: String,
88
#[prop(into)] placeholder: String,
99
#[prop(into, default = String::new())] class: String,

crates/frontend/src/components/change_summary.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ pub fn gen_change_table(
8181
}
8282

8383
#[component]
84-
fn no_change() -> impl IntoView {
84+
fn NoChange() -> impl IntoView {
8585
view! { <div class="text-gray-500 text-center text-sm">"No changes detected."</div> }
8686
}
8787

8888
#[component]
89-
pub fn change_summary(
89+
pub fn ChangeSummary(
9090
#[prop(into)] title: String,
9191
#[prop(into, default = "Config Key".to_string())] key_column: String,
9292
old_values: Map<String, Value>,
@@ -107,7 +107,7 @@ pub fn change_summary(
107107
}
108108

109109
#[component]
110-
pub fn json_change_summary(
110+
pub fn JsonChangeSummary(
111111
#[prop(into)] title: String,
112112
old_values: Option<Value>,
113113
new_values: Option<Value>,
@@ -199,7 +199,7 @@ pub fn json_change_summary(
199199
}
200200

201201
#[component]
202-
pub fn change_log_popup(
202+
pub fn ChangeLogPopup(
203203
#[prop(into)] title: String,
204204
#[prop(into)] description: String,
205205
#[prop(into, default = "Yes".to_string())] confirm_text: String,

crates/frontend/src/components/cohort_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn validate_cohort_info(enum_name: &str, enum_value: &Value) -> Result<String, S
6868
}
6969

7070
#[component]
71-
pub fn cohort_schema(
71+
pub fn CohortSchema(
7272
dimension_schema: Value,
7373
#[prop(into)] on_change: Callback<Value>,
7474
#[prop(optional)] cohort_based_on: Option<DimensionResponse>,
@@ -405,7 +405,7 @@ enum CohortInputType {
405405
}
406406

407407
#[component]
408-
fn cohort_form(
408+
fn CohortForm(
409409
#[prop(into, default = String::new())] cohort_name: String,
410410
value: Value,
411411
#[prop(into)] on_change: Callback<(String, Value), Result<(), String>>,

crates/frontend/src/components/condition_pills.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn use_condition_collapser() -> WindowListenerHandle {
2929
}
3030

3131
#[component]
32-
pub fn condition_expression(
32+
pub fn ConditionExpression(
3333
#[prop(into)] id: String,
3434
#[prop(into)] list_id: String,
3535
condition: Condition,
@@ -87,7 +87,7 @@ pub fn condition_expression(
8787
}
8888

8989
#[component]
90-
pub fn condition(
90+
pub fn Condition(
9191
#[prop(into)] id: String,
9292
#[prop(into)] conditions: Conditions,
9393
#[prop(into, default=String::new())] class: String,

crates/frontend/src/components/context_card.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
};
1717

1818
#[component]
19-
fn option(
19+
fn Option(
2020
label: String,
2121
icon: String,
2222
#[prop(into)] on_click: Callback<(), ()>,
@@ -33,7 +33,7 @@ fn option(
3333
}
3434

3535
#[component]
36-
fn context_options(
36+
fn ContextOptions(
3737
#[prop(into)] handle_create_experiment: Callback<(), ()>,
3838
#[prop(into)] handle_delete_experiment: Callback<(), ()>,
3939
#[prop(into)] handle_clone: Callback<(), ()>,
@@ -82,7 +82,7 @@ fn context_options(
8282
}
8383

8484
#[component]
85-
pub fn context_card(
85+
pub fn ContextCard(
8686
context: Context,
8787
overrides: Map<String, Value>,
8888
#[prop(default = true)] show_actions: bool,

0 commit comments

Comments
 (0)