Skip to content

Commit

Permalink
chore: fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Dec 25, 2022
1 parent 9cb7a36 commit 06c043b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
20 changes: 9 additions & 11 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{array, collections::HashMap};
use std::collections::HashMap;

use crate::{
AlignSelf, Border, Col, Css, Display, Divide, Flex, Grid, Object, Overflow, PluginResult,
Expand All @@ -16,7 +16,6 @@ use tailwind_config::TailwindTheme;
macro_rules! lookup_plugin {
($def:ident, $map:tt, $target:expr) => {
pub fn $def<'a>(Value(rest): &Value, theme: &'a TailwindTheme) -> PluginResult<'a> {
println!("{}: {}", stringify!($def), rest);
simple_lookup(&theme.$map, rest, $target)
}
};
Expand All @@ -30,7 +29,6 @@ macro_rules! lookup_plugin {
macro_rules! array_plugin {
($def:ident, $options:expr, $target:expr) => {
pub fn $def<'a>(Value(rest): &Value, _theme: &'a TailwindTheme) -> PluginResult<'a> {
println!("{}: {}", stringify!($def), rest);
$options
.iter()
.find(|&x| x == rest)
Expand Down Expand Up @@ -203,7 +201,7 @@ fn simple_lookup_map<'a, V>(
hashmap
.get(search)
.map(|val| to_lit(&[(output, &f(val))]))
.ok_or_else(|| vec![])
.ok_or_else(Vec::new)
}

lookup_plugin_opt!(transition, transition_property, "transitionProperty");
Expand Down Expand Up @@ -463,7 +461,7 @@ pub fn transform_origin<'a>(Value(rest): &Value, _theme: &'a TailwindTheme) -> P

pub fn text<'a>(value: &SubjectValue, theme: &'a TailwindTheme) -> PluginResult<'a> {
text_size(value, theme)
.or_else(|e| text_color(value, theme))
.or_else(|_e| text_color(value, theme))
.or_else(|e| match value {
SubjectValue::Value(v) => text_align(v, theme),
SubjectValue::Css(_) => Err(e),
Expand Down Expand Up @@ -581,18 +579,18 @@ pub fn outline<'a>(rest: Option<&Value>, theme: &'a TailwindTheme) -> PluginResu
Some(Value("double")) => Ok(to_lit(&[("outlineStyle", "double")])),
Some(Value("hidden")) => Ok(to_lit(&[("outlineStyle", "hidden")])),
Some(rest) => simple_lookup(&theme.colors, rest.0, "outlineColor")
.or_else(|e| simple_lookup(&theme.outline_offset, rest.0, "outlineOffset"))
.or_else(|e| simple_lookup(&theme.outline_width, rest.0, "outlineWidth")),
.or_else(|_e| simple_lookup(&theme.outline_offset, rest.0, "outlineOffset"))
.or_else(|_e| simple_lookup(&theme.outline_width, rest.0, "outlineWidth")),
}
}

pub fn bg<'a>(val: &SubjectValue, theme: &'a TailwindTheme) -> PluginResult<'a> {
match val {
SubjectValue::Value(Value(rest)) => simple_lookup(&theme.colors, rest, "backgroundColor")
.or_else(|e| simple_lookup(&theme.background_image, rest, "backgroundImage"))
.or_else(|e| simple_lookup(&theme.background_size, rest, "backgroundSize"))
.or_else(|e| simple_lookup(&theme.background_position, rest, "backgroundPosition"))
.or_else(|e| bg_repeat(&Value(rest), theme)),
.or_else(|_e| simple_lookup(&theme.background_image, rest, "backgroundImage"))
.or_else(|_e| simple_lookup(&theme.background_size, rest, "backgroundSize"))
.or_else(|_e| simple_lookup(&theme.background_position, rest, "backgroundPosition"))
.or_else(|_e| bg_repeat(&Value(rest), theme)),
SubjectValue::Css(Css(css)) => Ok(to_lit(&[("background", css)])),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tailwind-parse/src/eval/prose.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use stailwc_swc_utils::{merge_literals, named_literal, to_lit};
use swc_core::ecma::ast::ObjectLit;

use tailwind_config::TailwindTheme;

use crate::{PluginResult, Prose, SubjectValue};
Expand Down
2 changes: 2 additions & 0 deletions crates/tailwind-parse/src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ pub type PluginResult<'a> = Result<ObjectLit, Vec<&'a str>>;
enum PluginType<'a> {
Singular(fn() -> ObjectLit),
Required(fn(&Value, &'a TailwindTheme) -> PluginResult<'a>),
#[allow(clippy::type_complexity)]
RequiredBox(Box<dyn Fn(&Value, &'a TailwindTheme) -> PluginResult<'a>>),
#[allow(clippy::type_complexity)]
OptionalAbitraryBox(Box<dyn Fn(&Option<SubjectValue>, &'a TailwindTheme) -> PluginResult<'a>>),
Optional(fn(Option<&Value>, &'a TailwindTheme) -> PluginResult<'a>),
RequiredArbitrary(fn(&SubjectValue, &'a TailwindTheme) -> PluginResult<'a>),
Expand Down

0 comments on commit 06c043b

Please sign in to comment.