Skip to content

Commit 366c15a

Browse files
committed
chore: add clippy lints and package exclusions for crates.io
1 parent c310ee7 commit 366c15a

File tree

10 files changed

+45
-12
lines changed

10 files changed

+45
-12
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
[package]
22
name = "dioxus-maplibre"
3-
version = "0.0.2"
3+
version = "0.0.3"
44
edition = "2024"
55
description = "MapLibre GL JS wrapper for Dioxus 0.7"
66
license = "MIT OR Apache-2.0"
77
repository = "https://github.com/Nevaberry/dioxus-maplibre"
88
keywords = ["dioxus", "maplibre", "maps", "gis", "wasm"]
99
categories = ["gui", "wasm", "web-programming"]
10+
exclude = ["e2e/", "examples/", "temp/", "test-results/", ".github/"]
11+
12+
[lints.rust]
13+
unsafe_code = "forbid"
14+
15+
[lints.clippy]
16+
all = { level = "warn", priority = -1 }
17+
pedantic = { level = "warn", priority = -1 }
18+
nursery = { level = "warn", priority = -1 }
19+
module_name_repetitions = "allow"
20+
must_use_candidate = "allow"
21+
needless_raw_string_hashes = "allow"
22+
doc_markdown = "allow"
23+
missing_const_for_fn = "allow"
24+
suboptimal_flops = "allow"
25+
too_many_lines = "allow"
26+
option_if_let_else = "allow"
27+
pub_with_shorthand = "allow"
28+
redundant_pub_crate = "allow"
1029

1130
[dependencies]
1231
dioxus = "0.7"

src/components/circle_layer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
55
use crate::context::MapContext;
66

77
/// Props for the CircleLayer component
8-
#[derive(Props, Clone, PartialEq)]
8+
#[derive(Props, Clone, PartialEq, Eq)]
99
pub struct CircleLayerProps {
1010
/// Unique layer ID
1111
pub id: String,
@@ -39,11 +39,14 @@ pub struct CircleLayerProps {
3939
/// }
4040
/// ```
4141
#[component]
42+
#[allow(unused_variables)] // props only used on wasm32
4243
pub fn CircleLayer(props: CircleLayerProps) -> Element {
4344
// Get map context from parent
45+
#[allow(unused_variables)] // only used on wasm32
4446
let ctx = use_context::<MapContext>();
4547

4648
// Track whether layer has been added
49+
#[allow(unused_variables, unused_mut)] // only used on wasm32
4750
let mut layer_added = use_signal(|| false);
4851

4952
// Only do JS interop on wasm targets

src/components/geojson_source.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ pub struct GeoJsonSourceProps {
3333
#[component]
3434
pub fn GeoJsonSource(props: GeoJsonSourceProps) -> Element {
3535
// Get map context from parent
36+
#[allow(unused_variables)] // only used on wasm32
3637
let ctx = use_context::<MapContext>();
3738

3839
// Track whether source has been added
40+
#[allow(unused_variables, unused_mut)] // only used on wasm32
3941
let mut source_added = use_signal(|| false);
4042

4143
// Track previous data for change detection
42-
let mut prev_data = use_signal(|| String::new());
44+
#[allow(unused_variables, unused_mut)] // only used on wasm32
45+
let mut prev_data = use_signal(String::new);
4346

4447
// Only do JS interop on wasm targets
4548
#[cfg(target_arch = "wasm32")]

src/components/map.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ pub fn Map(props: MapProps) -> Element {
7878
let container_id = format!("{map_id}_container");
7979

8080
// Track if map is ready
81+
#[allow(unused_mut)] // mut needed only on wasm32
8182
let mut is_ready = use_signal(|| false);
8283

8384
// Track if initialization has been started (to prevent multiple inits)
85+
#[allow(unused_variables, unused_mut)] // only used on wasm32
8486
let mut init_started = use_signal(|| false);
8587

8688
// Create context for child components
8789
let ctx = MapContext {
88-
map_id: map_id.clone(),
90+
map_id,
8991
is_ready,
9092
};
9193
use_context_provider(|| ctx);

src/components/marker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ pub struct MarkerProps {
3131
#[component]
3232
pub fn Marker(props: MarkerProps) -> Element {
3333
// Get map context from parent
34+
#[allow(unused_variables)] // only used on wasm32
3435
let ctx = use_context::<MapContext>();
3536

3637
// Generate marker ID if not provided
38+
#[allow(unused_variables)] // only used on wasm32
3739
let marker_id = use_hook(|| {
3840
props.id.clone().unwrap_or_else(|| {
3941
format!("marker_{}", uuid::Uuid::new_v4().to_string().replace('-', ""))

src/events.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ pub struct LayerHoverEvent {
6363
/// Internal event enum for communication from JS
6464
#[derive(Debug, Clone, Serialize, Deserialize)]
6565
#[serde(tag = "type")]
66-
pub(crate) enum MapEvent {
66+
#[allow(dead_code)] // Reserved for future typed event parsing
67+
pub enum MapEvent {
6768
#[serde(rename = "click")]
6869
Click(MapClickEvent),
6970
#[serde(rename = "marker_click")]

src/interop/bridge.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
//! This module generates the JavaScript code needed to interact with MapLibre GL JS.
44
//! Maps are stored in `window.__dioxus_maplibre_maps[map_id]` for lifecycle management.
55
6+
// These functions generate JS strings and are only called on wasm32 targets.
7+
// On other targets they appear unused but we keep them available for testing.
8+
#![allow(dead_code)]
9+
610
use uuid::Uuid;
711

812
/// Generate a unique map ID
@@ -218,12 +222,11 @@ pub fn add_marker_js(
218222
r#"
219223
const el = document.createElement('div');
220224
el.className = 'maplibre-marker-emoji';
221-
el.innerHTML = '{}';
225+
el.innerHTML = '{e}';
222226
el.style.fontSize = '28px';
223227
el.style.cursor = 'pointer';
224228
el.style.filter = 'drop-shadow(0 2px 4px rgba(0,0,0,0.5))';
225-
"#,
226-
e
229+
"#
227230
),
228231
None => String::new(),
229232
};

src/interop/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
33
mod bridge;
44

5-
pub(crate) use bridge::*;
5+
pub use bridge::*;

src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl Bounds {
8282
/// Get the center of the bounds
8383
pub fn center(&self) -> LatLng {
8484
LatLng {
85-
lat: (self.sw.lat + self.ne.lat) / 2.0,
86-
lng: (self.sw.lng + self.ne.lng) / 2.0,
85+
lat: f64::midpoint(self.sw.lat, self.ne.lat),
86+
lng: f64::midpoint(self.sw.lng, self.ne.lng),
8787
}
8888
}
8989
}

0 commit comments

Comments
 (0)