Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Nov 26, 2024
1 parent 3ac26f9 commit 1dffca0
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions crates/oxc_macros/src/declare_all_lint_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,21 @@ impl Parse for LintRuleMeta {
let path = input.parse::<syn::Path>()?;

let segments = &path.segments;
let last_two_segments = segments.iter().rev().take(2).collect::<Vec<_>>(); // Collect the last two segments in reverse order
let combined = last_two_segments
let combined = segments
.iter()
.rev()
.take(2)
.rev()
.map(|seg| seg.ident.to_string().to_case(Case::Pascal))
.join("");

let combined = combined.to_case(Case::Pascal);

let name = syn::parse_str(
//&path.segments.iter().last().unwrap().ident.to_string().to_case(Case::Pascal),
&combined,
)
.unwrap();
Ok(Self {
enum_name: name,
rule_name: syn::parse_str(
&path.segments.iter().last().unwrap().ident.to_string().to_case(Case::Pascal),
//&combined,
)
.unwrap(),
path,
})
let enum_name = syn::parse_str(&combined)?;
let rule_name = syn::parse_str(
&path.segments.iter().last().unwrap().ident.to_string().to_case(Case::Pascal),
)?;
Ok(Self { rule_name, enum_name, path })
}
}

Expand All @@ -60,7 +52,7 @@ impl Parse for AllLintRulesMeta {
pub fn declare_all_lint_rules(metadata: AllLintRulesMeta) -> TokenStream {
let AllLintRulesMeta { rules } = metadata;

let mut use_stmts: Vec<&syn::Path> = Vec::with_capacity(rules.len());
let mut use_stmts = Vec::with_capacity(rules.len());
let mut struct_names = Vec::with_capacity(rules.len());
let mut struct_rule_names = Vec::with_capacity(rules.len());
let mut plugin_names = Vec::with_capacity(rules.len());
Expand Down

0 comments on commit 1dffca0

Please sign in to comment.