Skip to content

Commit

Permalink
fix: cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Sep 19, 2024
1 parent a5d487f commit a2aac1f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ members = [
"crates/binding",
]
resolver = "2"

[profile.release]
lto = true
3 changes: 0 additions & 3 deletions crates/binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ svgr-rs = { path = "../core", features = ["node"] }

[build-dependencies]
napi-build = "2.0.1"

[profile.release]
lto = true
5 changes: 1 addition & 4 deletions crates/binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ pub async fn transform_node(
state: Option<State>,
) -> napi::bindgen_prelude::Result<String> {
let config: Config = get_deserialized(&config)?;
let state = match state {
Some(state) => state,
None => Default::default(),
};
let state = state.unwrap_or_default();
match transform(code, config, state) {
Ok(result) => napi::bindgen_prelude::Result::Ok(result),
Err(reason) => napi::bindgen_prelude::Result::Err(napi::bindgen_prelude::Error::from_reason(
Expand Down
3 changes: 0 additions & 3 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ linked_hash_set = "0.1.4"

[dev-dependencies]
testing = "0.32.5"

[profile.release]
lto = true
2 changes: 1 addition & 1 deletion crates/core/src/svg_dynamic_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Visitor {
..
}) = attr
{
if ident.sym.to_string() == "id" {
if ident.sym.as_str() == "id" {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/svg_em_dimensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl VisitMut for Visitor {
fn visit_mut_jsx_opening_element(&mut self, n: &mut JSXOpeningElement) {
let is_svg = ELEMENTS.iter().any(|element| {
if let JSXElementName::Ident(ident) = n.name.clone() {
return ident.sym.to_string() == *element;
return ident.sym.as_str() == *element;
}
false
});
Expand All @@ -74,7 +74,7 @@ impl VisitMut for Visitor {
.iter()
.enumerate()
.for_each(|(index, attr)| {
if ident.sym.to_string() == *attr {
if ident.sym.as_str() == *attr {
match *attr {
"height" => {
jsx_attr.value.replace(get_value(self.height.as_ref()));
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/transform_react_native_svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl SvgElementVisitor {
impl VisitMut for SvgElementVisitor {
fn visit_mut_jsx_element(&mut self, n: &mut JSXElement) {
if let JSXElementName::Ident(ident) = &mut n.opening.name {
if ident.sym.to_string() == "svg" {
if ident.sym.as_str() == "svg" {
let mut jsx_element_visitor = JSXElementVisitor::new(
self.replaced_components.clone(),
self.unsupported_components.clone(),
Expand Down Expand Up @@ -206,7 +206,7 @@ impl ImportDeclVisitor {

impl VisitMut for ImportDeclVisitor {
fn visit_mut_import_decl(&mut self, n: &mut ImportDecl) {
if n.src.value.to_string() == "react-native-svg" {
if n.src.value.as_str() == "react-native-svg" {
for component in self.replaced_components.borrow().iter() {
if n.specifiers.iter().any(|specifier| {
if let ImportSpecifier::Named(named) = specifier {
Expand All @@ -233,7 +233,7 @@ impl VisitMut for ImportDeclVisitor {
}

self.import_decl_span = Some(n.span);
} else if n.src.value.to_string() == "expo" {
} else if n.src.value.as_str() == "expo" {
n.specifiers
.push(ImportSpecifier::Named(ImportNamedSpecifier {
local: Ident::new("Svg".into(), DUMMY_SP, SyntaxContext::empty()),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/transform_svg_component/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ fn get_or_create_import(
.specifiers
.iter()
.any(|specifier| matches!(specifier, ImportSpecifier::Namespace(_)));
if !is_namespace_import && import_decl.src.value.to_string() == soruce_value {
if !is_namespace_import && import_decl.src.value.as_str() == soruce_value {
existing = Some(import_decl);
break;
}
Expand Down

0 comments on commit a2aac1f

Please sign in to comment.