oxc-project/oxc · error · OxcDiagnostic

Expected to return a boolean value in "{name}" emits validat

Error message

Expected to return a boolean value in "{name}" emits validator.

What it means

Emitted by run of the vue return-in-emits-validator rule when an emits validator function fails to return a boolean on all code paths — it may return nothing or non-boolean values. Vue treats validators as predicates, so any non-boolean return breaks event validation.

Source

Thrown at crates/oxc_linter/src/rules/vue/return_in_emits_validator.rs:17

use oxc_ast::{
    AstKind,
    ast::{ArrowFunctionExpression, Expression, Function, ReturnStatement},
};
use oxc_ast_visit::{VisitJs, walk_js};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::ScopeFlags;
use oxc_span::Span;

use crate::{
    AstNode, context::LintContext, frameworks::FrameworkOptions, rule::Rule,
    utils::is_vue_component_options_object,
};

fn expected_boolean_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!(
        "Expected to return a boolean value in \"{name}\" emits validator."
    ))
    .with_label(span)
}

fn expected_true_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Expected to return a true value in \"{name}\" emits validator."))
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct ReturnInEmitsValidator;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Enforce that a `return` statement is present in `emits` validators
    /// (in Vue.js 3.0.0+).

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Make the validator return an explicit boolean from every branch
  2. Wrap the check, e.g. emits: { change: (value) => typeof value === 'number' }
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/vue/return_in_emits_validator.rs:17 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/9d48f198c1f1bfa9. Report an issue: GitHub.