oxc_transformer 0.136.0

A collection of JavaScript tools written in Rust.
Documentation
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;

// TODO: Re-enable these diagnostics once JSX option validation is restored.

#[cold]
#[expect(dead_code)]
pub fn pragma_and_pragma_frag_cannot_be_set() -> OxcDiagnostic {
    OxcDiagnostic::warn("pragma and pragmaFrag cannot be set when runtime is automatic.")
        .with_help("Remove `pragma` and `pragmaFrag` options.")
}

#[cold]
#[cfg_attr(not(test), expect(dead_code))]
pub fn invalid_pragma() -> OxcDiagnostic {
    OxcDiagnostic::warn(
        "pragma and pragmaFrag must be valid member expressions such as `h`, `React.createElement`, `this.h`, or `import.meta.h`.",
    )
    .with_help("Fix `pragma` and `pragmaFrag` options.")
}

#[cold]
#[expect(dead_code)]
pub fn import_source_cannot_be_set() -> OxcDiagnostic {
    OxcDiagnostic::warn("importSource cannot be set when runtime is classic.")
        .with_help("Remove `importSource` option.")
}

#[cold]
#[expect(dead_code)]
pub fn invalid_import_source() -> OxcDiagnostic {
    OxcDiagnostic::warn("importSource cannot be an empty string or longer than u32::MAX bytes")
        .with_help("Fix `importSource` option.")
}

#[cold]
pub fn namespace_does_not_support(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning.")
        .with_label(span)
}

#[cold]
pub fn valueless_key(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Please provide an explicit key value. Using \"key\" as a shorthand for \"key={true}\" is not allowed.")
        .with_label(span)
}