mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 09:09:21 -05:00
clippy CI and all warnings fixed
This commit is contained in:
parent
4454f87f8e
commit
5e04455640
11 changed files with 25 additions and 28 deletions
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
@ -23,17 +23,17 @@ jobs:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt
|
components: rustfmt, clippy
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
- name: Check function count badge
|
- name: Check function count badge
|
||||||
run: python3 docs/generate_count_badge.py --check
|
run: python3 docs/generate_count_badge.py --check
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt --check
|
run: cargo fmt --check
|
||||||
# - name: Check if the README is up to date.
|
- name: Clippy check
|
||||||
# run: |
|
uses: auguwu/clippy-action@1.1.2
|
||||||
# cargo install cargo-rdme
|
with:
|
||||||
# cargo rdme --check
|
args: --all-features --tests -- -D warnings
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --all-features
|
run: cargo test --all-features
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ homepage = "https://leptos-use.rs"
|
||||||
leptos = "0.3.0"
|
leptos = "0.3.0"
|
||||||
wasm-bindgen = "0.2.86"
|
wasm-bindgen = "0.2.86"
|
||||||
js-sys = "0.3.63"
|
js-sys = "0.3.63"
|
||||||
default-struct-builder = "0.2.0"
|
default-struct-builder = "0.2.1"
|
||||||
num = { version = "0.4.0", optional = true }
|
num = { version = "0.4.0", optional = true }
|
||||||
serde = { version = "1.0.163", optional = true }
|
serde = { version = "1.0.163", optional = true }
|
||||||
serde_json = { version = "1.0.96", optional = true }
|
serde_json = { version = "1.0.96", optional = true }
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<br/>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/synphonyte/leptos-use">
|
<a href="https://github.com/synphonyte/leptos-use">
|
||||||
<img src="https://raw.githubusercontent.com/synphonyte/leptos-use/main/docs/logo.svg" alt="Leptos-Use – Collection of essential Leptos utilities" width="150"/>
|
<img src="https://raw.githubusercontent.com/synphonyte/leptos-use/main/docs/logo.svg" alt="Leptos-Use – Collection of essential Leptos utilities" width="150"/>
|
||||||
|
|
|
@ -200,7 +200,7 @@ where
|
||||||
Ok(ref serialized) => match store.get_item(&k) {
|
Ok(ref serialized) => match store.get_item(&k) {
|
||||||
Ok(old_value) => {
|
Ok(old_value) => {
|
||||||
if old_value.as_ref() != Some(serialized) {
|
if old_value.as_ref() != Some(serialized) {
|
||||||
if let Err(e) = store.set_item(&k, &serialized) {
|
if let Err(e) = store.set_item(&k, serialized) {
|
||||||
on_err(UseStorageError::StorageAccessError(e));
|
on_err(UseStorageError::StorageAccessError(e));
|
||||||
} else {
|
} else {
|
||||||
let mut event_init = web_sys::CustomEventInit::new();
|
let mut event_init = web_sys::CustomEventInit::new();
|
||||||
|
|
|
@ -149,7 +149,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
let cleanup_prev_el = Rc::clone(&cleanup_prev_element);
|
let cleanup_prev_el = Rc::clone(&cleanup_prev_element);
|
||||||
let closure = closure_js.clone();
|
let closure = closure_js;
|
||||||
create_effect(cx, move |_| {
|
create_effect(cx, move |_| {
|
||||||
cleanup_prev_el.borrow()();
|
cleanup_prev_el.borrow()();
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn use_media_query(cx: Scope, query: impl Into<MaybeSignal<String>>) -> Sign
|
||||||
let (matches, set_matches) = create_signal(cx, false);
|
let (matches, set_matches) = create_signal(cx, false);
|
||||||
|
|
||||||
let media_query: Rc<RefCell<Option<web_sys::MediaQueryList>>> = Rc::new(RefCell::new(None));
|
let media_query: Rc<RefCell<Option<web_sys::MediaQueryList>>> = Rc::new(RefCell::new(None));
|
||||||
let remove_listener: Rc<RefCell<Option<Box<dyn Fn()>>>> = Rc::new(RefCell::new(None));
|
let remove_listener: RemoveListener = Rc::new(RefCell::new(None));
|
||||||
|
|
||||||
let rem_listener = Rc::clone(&remove_listener);
|
let rem_listener = Rc::clone(&remove_listener);
|
||||||
|
|
||||||
|
@ -88,3 +88,5 @@ pub fn use_media_query(cx: Scope, query: impl Into<MaybeSignal<String>>) -> Sign
|
||||||
|
|
||||||
matches.into()
|
matches.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RemoveListener = Rc<RefCell<Option<Box<dyn Fn()>>>>;
|
||||||
|
|
|
@ -174,7 +174,7 @@ where
|
||||||
cx,
|
cx,
|
||||||
target.clone(),
|
target.clone(),
|
||||||
touchmove,
|
touchmove,
|
||||||
touch_handler.clone(),
|
touch_handler,
|
||||||
event_listener_options.clone(),
|
event_listener_options.clone(),
|
||||||
);
|
);
|
||||||
if options.reset_on_touch_ends {
|
if options.reset_on_touch_ends {
|
||||||
|
|
|
@ -150,10 +150,10 @@ impl Default for UseResizeObserverOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<web_sys::ResizeObserverOptions> for UseResizeObserverOptions {
|
impl From<UseResizeObserverOptions> for web_sys::ResizeObserverOptions {
|
||||||
fn into(self) -> web_sys::ResizeObserverOptions {
|
fn from(val: UseResizeObserverOptions) -> Self {
|
||||||
let mut options = web_sys::ResizeObserverOptions::new();
|
let mut options = web_sys::ResizeObserverOptions::new();
|
||||||
options.box_(self.box_);
|
options.box_(val.box_);
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,8 +210,7 @@ where
|
||||||
let scroll = scroll_to.clone();
|
let scroll = scroll_to.clone();
|
||||||
let set_x = Box::new(move |x| scroll(Some(x), None));
|
let set_x = Box::new(move |x| scroll(Some(x), None));
|
||||||
|
|
||||||
let scroll = scroll_to.clone();
|
let set_y = Box::new(move |y| scroll_to(None, Some(y)));
|
||||||
let set_y = Box::new(move |y| scroll(None, Some(y)));
|
|
||||||
|
|
||||||
let (is_scrolling, set_is_scrolling) = create_signal(cx, false);
|
let (is_scrolling, set_is_scrolling) = create_signal(cx, false);
|
||||||
|
|
||||||
|
@ -475,9 +474,9 @@ pub enum ScrollBehavior {
|
||||||
Smooth,
|
Smooth,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<web_sys::ScrollBehavior> for ScrollBehavior {
|
impl From<ScrollBehavior> for web_sys::ScrollBehavior {
|
||||||
fn into(self) -> web_sys::ScrollBehavior {
|
fn from(val: ScrollBehavior) -> Self {
|
||||||
match self {
|
match val {
|
||||||
ScrollBehavior::Auto => web_sys::ScrollBehavior::Auto,
|
ScrollBehavior::Auto => web_sys::ScrollBehavior::Auto,
|
||||||
ScrollBehavior::Smooth => web_sys::ScrollBehavior::Smooth,
|
ScrollBehavior::Smooth => web_sys::ScrollBehavior::Smooth,
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,12 +62,8 @@ impl FilterOptions {
|
||||||
R: 'static,
|
R: 'static,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
FilterOptions::Debounce { ms, options } => {
|
FilterOptions::Debounce { ms, options } => Box::new(debounce_filter(*ms, *options)),
|
||||||
Box::new(debounce_filter(ms.clone(), *options))
|
FilterOptions::Throttle { ms, options } => Box::new(throttle_filter(*ms, *options)),
|
||||||
}
|
|
||||||
FilterOptions::Throttle { ms, options } => {
|
|
||||||
Box::new(throttle_filter(ms.clone(), *options))
|
|
||||||
}
|
|
||||||
FilterOptions::None => Box::new(|invoke: Box<dyn CloneableFnWithReturn<R>>| {
|
FilterOptions::None => Box::new(|invoke: Box<dyn CloneableFnWithReturn<R>>| {
|
||||||
Rc::new(RefCell::new(Some(invoke())))
|
Rc::new(RefCell::new(Some(invoke())))
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -160,14 +160,14 @@ where
|
||||||
|
|
||||||
create_effect(cx, move |did_run_before| {
|
create_effect(cx, move |did_run_before| {
|
||||||
if !is_active() {
|
if !is_active() {
|
||||||
return ();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let deps_value = deps();
|
let deps_value = deps();
|
||||||
|
|
||||||
if !options.immediate && did_run_before.is_none() {
|
if !options.immediate && did_run_before.is_none() {
|
||||||
prev_deps_value.replace(Some(deps_value));
|
prev_deps_value.replace(Some(deps_value));
|
||||||
return ();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_deps_value.replace(Some(deps_value.clone()));
|
cur_deps_value.replace(Some(deps_value.clone()));
|
||||||
|
@ -181,8 +181,6 @@ where
|
||||||
prev_callback_value.replace(callback_value);
|
prev_callback_value.replace(callback_value);
|
||||||
|
|
||||||
prev_deps_value.replace(Some(deps_value));
|
prev_deps_value.replace(Some(deps_value));
|
||||||
|
|
||||||
()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
|
|
Loading…
Add table
Reference in a new issue