From 2e9faf0bdc2c54235fdb7b153a90a1d064b5d104 Mon Sep 17 00:00:00 2001 From: EthanShoeDev <13422990+EthanShoeDev@users.noreply.github.com> Date: Mon, 22 Sep 2025 00:35:35 -0400 Subject: [PATCH] lint passing --- packages/react-native-uniffi-russh/package.json | 3 +++ .../rust/uniffi-russh/justfile | 8 +++++++- .../rust/uniffi-russh/src/ssh_connection.rs | 8 ++++---- .../rust/uniffi-russh/src/ssh_shell.rs | 8 ++++---- packages/react-native-uniffi-russh/turbo.jsonc | 16 ++++++++++++++-- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/packages/react-native-uniffi-russh/package.json b/packages/react-native-uniffi-russh/package.json index 8c3a67b..a93b268 100644 --- a/packages/react-native-uniffi-russh/package.json +++ b/packages/react-native-uniffi-russh/package.json @@ -42,6 +42,9 @@ "build:native": "tsx scripts/native-build.ts", "build:bob": "bob build", "lint:rust": "cd rust/uniffi-russh && just lint", + "lint:rust:check": "cd rust/uniffi-russh && just lint-check", + "fmt:rust": "cd rust/uniffi-russh && just fmt", + "fmt:rust:check": "cd rust/uniffi-russh && just fmt-check", "update-rust": "cd rust/uniffi-russh && just update-deps", "test": "jest", "release": "release-it --only-version" diff --git a/packages/react-native-uniffi-russh/rust/uniffi-russh/justfile b/packages/react-native-uniffi-russh/rust/uniffi-russh/justfile index 9e9f555..8876f16 100644 --- a/packages/react-native-uniffi-russh/rust/uniffi-russh/justfile +++ b/packages/react-native-uniffi-russh/rust/uniffi-russh/justfile @@ -4,6 +4,9 @@ default: @just --list lint: + cargo clippy --all-targets --all-features --fix --allow-dirty -- -D warnings + +lint-check: cargo clippy --all-targets --all-features -- -D warnings # Update all Cargo dependencies to the latest allowed by Cargo.toml @@ -16,4 +19,7 @@ test: fmt: - cargo fmt \ No newline at end of file + cargo fmt + +fmt-check: + cargo fmt -- --check \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_connection.rs b/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_connection.rs index 6e273ae..e3781a9 100644 --- a/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_connection.rs +++ b/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_connection.rs @@ -70,7 +70,6 @@ pub trait ConnectionDisconnectedCallback: Send + Sync { fn on_change(&self, connection_id: String); } -/// Snapshot of current connection info for property-like access in TS. #[derive(Debug, Clone, PartialEq, uniffi::Record)] pub struct SshConnectionInfo { pub connection_id: String, @@ -82,8 +81,9 @@ pub struct SshConnectionInfo { #[derive(uniffi::Object)] pub struct SshConnection { - pub(crate) info: SshConnectionInfo, - pub(crate) on_disconnected_callback: Option>, + pub info: SshConnectionInfo, + pub on_disconnected_callback: Option>, + pub(crate) client_handle: AsyncMutex>, pub(crate) shells: AsyncMutex>>, @@ -265,7 +265,7 @@ impl SshConnection { sender: tx, listener_tasks: Arc::new(Mutex::new(HashMap::new())), next_listener_id: AtomicU64::new(1), - default_coalesce_ms, + coalesce_ms: default_coalesce_ms, rt_handle: tokio::runtime::Handle::current(), }); diff --git a/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_shell.rs b/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_shell.rs index f5e695a..0363bfe 100644 --- a/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_shell.rs +++ b/packages/react-native-uniffi-russh/rust/uniffi-russh/src/ssh_shell.rs @@ -116,8 +116,8 @@ pub struct ShellSessionInfo { #[derive(uniffi::Object)] pub struct ShellSession { - pub(crate) info: ShellSessionInfo, - pub(crate) on_closed_callback: Option>, + pub info: ShellSessionInfo, + pub on_closed_callback: Option>, // Weak backref; avoid retain cycle. pub(crate) parent: std::sync::Weak, @@ -140,7 +140,7 @@ pub struct ShellSession { // Listener tasks management pub(crate) listener_tasks: Arc>>>, pub(crate) next_listener_id: AtomicU64, - pub(crate) default_coalesce_ms: AtomicU64, + pub(crate) coalesce_ms: AtomicU64, pub(crate) rt_handle: tokio::runtime::Handle, } @@ -383,7 +383,7 @@ impl ShellSession { let replay = self.read_buffer(opts.cursor.clone(), None); let mut rx = self.sender.subscribe(); let id = self.next_listener_id.fetch_add(1, Ordering::Relaxed); - let default_coalesce_ms = self.default_coalesce_ms.load(Ordering::Relaxed) as u32; + let default_coalesce_ms = self.coalesce_ms.load(Ordering::Relaxed) as u32; let coalesce_ms = opts.coalesce_ms.unwrap_or(default_coalesce_ms); let rt = self.rt_handle.clone(); diff --git a/packages/react-native-uniffi-russh/turbo.jsonc b/packages/react-native-uniffi-russh/turbo.jsonc index a8b0602..4a8e96c 100644 --- a/packages/react-native-uniffi-russh/turbo.jsonc +++ b/packages/react-native-uniffi-russh/turbo.jsonc @@ -3,13 +3,22 @@ "extends": ["//"], "tasks": { // Default overrides + "fmt": { "with": ["//#fmt:root", "fmt:rust"] }, + "fmt:check": { "with": ["//#fmt:check:root", "fmt:rust:check"] }, "lint": { - "dependsOn": ["fmt", "^build", "build:bob"], + "dependsOn": ["fmt", "^build", "build:bob", "fmt:rust"], "with": ["typecheck", "//#lint:root", "lint:rust"], }, "lint:check": { "dependsOn": ["^build", "build:bob"], - "with": ["fmt:check", "typecheck", "//#lint:check:root", "lint:rust"], + "with": [ + "fmt:check", + "typecheck", + "//#lint:check:root", + "lint:rust", + "lint:rust:check", + "fmt:rust:check", + ], }, "build": { "dependsOn": ["build:bob"], @@ -20,6 +29,9 @@ // Special tasks "lint:rust": {}, + "lint:rust:check": {}, + "fmt:rust": {}, + "fmt:rust:check": {}, "build:bob": { "dependsOn": ["build:native"], "inputs": ["src/**"],