oxc-project/oxc · error · OxcDiagnostic
Expected to return a true value in "{name}" emits validator.
Error message
Expected to return a true value in "{name}" emits validator. What it means
Emitted by run of the vue return-in-emits-validator rule (expected_true_diagnostic) when an emits validator always returns the same value such as literal true regardless of the payload, meaning it performs no actual validation. It is a semantic guard against no-op validators.
Source
Thrown at crates/oxc_linter/src/rules/vue/return_in_emits_validator.rs:24
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+).
///
/// ### Why is this bad?
///
/// An `emits` validator must return a boolean indicating whether the
/// emitted payload is valid. Forgetting to return a value (or returning
/// only falsy values) makes the validator effectively reject every emit,
/// breaking the component contract silently.View on GitHub (pinned to e1e7af627c)
Solutions
- Implement a real predicate that inspects the event payload
- Remove the validator entirely if all values are acceptable
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vue/return_in_emits_validator.rs:24 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/5c2d0ec4881491f3.
Report an issue: GitHub.