oxc-project/oxc · error · OxcDiagnostic

Return statement should not be used in Promise executor.

Error message

Return statement should not be used in Promise executor.

What it means

Lint diagnostic from eslint/no-promise-executor-return: a return statement with a value appears inside a Promise executor function. The return value is silently ignored, so it reads as if it resolved/rejected the promise when it did nothing; only resolve/reject control the outcome.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_promise_executor_return.rs:19

use oxc_ast::{
    AstKind,
    ast::{Argument, Expression, FunctionBody},
};
use oxc_ast_visit::VisitJs;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use schemars::JsonSchema;
use serde::Deserialize;

use crate::{
    AstNode,
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
};

fn no_promise_executor_return_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Return statement should not be used in Promise executor.")
        .with_help("Use `resolve()` or `reject()` instead of returning a value.")
        .with_label(span)
}

#[derive(Debug, Default, Clone, Deserialize)]
pub struct NoPromiseExecutorReturn(Box<NoPromiseExecutorReturnConfig>);

#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NoPromiseExecutorReturnConfig {
    /// If `true`, allows returning `void` expressions (e.g., `return void resolve()`).
    allow_void: bool,
}

impl std::ops::Deref for NoPromiseExecutorReturn {
    type Target = NoPromiseExecutorReturnConfig;

    fn deref(&self) -> &Self::Target {

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Call resolve(value) or reject(error) instead of returning
  2. Await an inner async IIFE if truly needed (allowIIFE option) rather than returning from the executor
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_promise_executor_return.rs:19 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/4babce4c042e0162. Report an issue: GitHub.