{"record":{"id":"fdc8b44e08e9f1bf","repo":"oxc-project/oxc","slug":"use-to-be-literal-instead-of-matcher-name","errorCode":null,"errorMessage":"Use `{to_be_literal}` instead of `{matcher_name}`.","messagePattern":"Use `(.+?)` instead of `(.+?)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vitest/prefer_strict_boolean_matchers.rs","lineNumber":16,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    rule::Rule,\n    utils::{PossibleJestNode, parse_expect_and_typeof_vitest_fn_call},\n};\n\nfn prefer_strict_boolean_matchers_diagnostic(span: Span, value: bool) -> OxcDiagnostic {\n    let (matcher_name, to_be_literal) =\n        if value { (\"toBeTruthy\", \"toBe(true)\") } else { (\"toBeFalsy\", \"toBe(false)\") };\n\n    OxcDiagnostic::warn(format!(\"Use `{to_be_literal}` instead of `{matcher_name}`.\"))\n        .with_help(\"Use strict boolean comparison instead of truthy/falsy coercion.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferStrictBooleanMatchers;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce using `toBe(true)` and `toBe(false)` over matchers that coerce types to boolean.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Truthy/falsy matchers coerce values to boolean and can hide type mistakes.\n    /// Strict boolean assertions make intent explicit and avoid accidental coercion.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vitest/prefer_strict_boolean_matchers.rs#L1-L34","documentation":"Emitted by the vitest/prefer-strict-boolean-matchers rule at an expectation using the loose boolean matchers `toBeTruthy()`/`toBeFalsy()`. It fires because these matchers accept any truthy/falsy value; strict `toBe(true)`/`toBe(false)` assertions catch accidental non-boolean values.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vitest/prefer_strict_boolean_matchers.rs:16 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace `toBeTruthy()` with `toBe(true)` and `toBeFalsy()` with `toBe(false)`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}