Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/oxlint/src-js/bindings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export declare function getBufferOffset(buffer: Uint8Array): number

/** JS callback to create a workspace. */
export type JsCreateWorkspaceCb =
((arg0: string) => Promise<undefined>)
((arg: string) => Promise<undefined>)

/** JS callback to destroy a workspace. */
export type JsDestroyWorkspaceCb =
((arg0: string) => void)
((arg: string) => void)

/** JS callback to lint a file. */
export type JsLintFileCb =
Expand Down
9 changes: 4 additions & 5 deletions apps/oxlint/src/js_plugins/external_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,8 @@ fn wrap_create_workspace(cb: JsCreateWorkspaceCb) -> ExternalLinterCreateWorkspa
Arc::new(Box::new(move |workspace_uri| {
let cb = &cb;
let res = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async move {
cb.call_async(FnArgs::from((workspace_uri,))).await?.into_future().await
})
tokio::runtime::Handle::current()
.block_on(async move { cb.call_async(workspace_uri).await?.into_future().await })
});

match res {
Expand All @@ -328,7 +327,7 @@ fn wrap_create_workspace(cb: JsCreateWorkspaceCb) -> ExternalLinterCreateWorkspa

/// Wrap `destroyWorkspace` JS callback as a normal Rust function.
fn wrap_destroy_workspace(cb: JsDestroyWorkspaceCb) -> ExternalLinterDestroyWorkspaceCb {
Arc::new(Box::new(move |workspace_uri: String| {
let _ = cb.call(FnArgs::from((workspace_uri,)), ThreadsafeFunctionCallMode::Blocking);
Arc::new(Box::new(move |workspace_uri| {
let _ = cb.call(workspace_uri, ThreadsafeFunctionCallMode::Blocking);
}))
}
8 changes: 4 additions & 4 deletions apps/oxlint/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ pub type JsSetupRuleConfigsCb = ThreadsafeFunction<
#[napi]
pub type JsCreateWorkspaceCb = ThreadsafeFunction<
// Arguments
FnArgs<(String,)>, // Workspace URI
String, // Workspace URI
// Return value
Promise<()>,
// Arguments (repeated)
FnArgs<(String,)>,
String,
// Error status
Status,
// CalleeHandled
Expand All @@ -100,11 +100,11 @@ pub type JsCreateWorkspaceCb = ThreadsafeFunction<
#[napi]
pub type JsDestroyWorkspaceCb = ThreadsafeFunction<
// Arguments
FnArgs<(String,)>, // Workspace URI
String, // Workspace URI
// Return value
(),
// Arguments (repeated)
FnArgs<(String,)>,
String,
// Error status
Status,
// CalleeHandled
Expand Down
Loading