{"record":{"id":"e290472586568030","repo":"oxc-project/oxc","slug":"prefer-tobeobject-for-object-assertions","errorCode":null,"errorMessage":"Prefer `toBeObject()` for object assertions","messagePattern":"Prefer `toBeObject\\(\\)` for object assertions","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vitest/prefer_to_be_object.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{Argument, BinaryOperator, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    context::LintContext,\n    rule::Rule,\n    utils::{\n        KnownMemberExpressionProperty, ParsedExpectFnCall, ParsedJestFnCallNew, PossibleJestNode,\n        parse_jest_fn_call,\n    },\n};\n\nfn prefer_to_be_object(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Prefer `toBeObject()` for object assertions\")\n        .with_help(\"Consider using `toBeObject()` to test if a value is an object.\")\n        .with_label(span)\n}\n\nfn is_parsed_instance_of_matcher_call(\n    parsed_expect_call: &ParsedExpectFnCall,\n    matcher: &KnownMemberExpressionProperty,\n) -> bool {\n    parsed_expect_call.args.len() == 1\n        && matches!(\n            parsed_expect_call.args.first(),\n            Some(Argument::Identifier(id)) if matcher.name().as_deref() == Some(\"toBeInstanceOf\") && id.name == \"Object\"\n        )\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferToBeObject;\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vitest/prefer_to_be_object.rs#L1-L37","documentation":"Emitted by the vitest/prefer-to-be-object rule at an object assertion written as a typeof/instanceof/constructor comparison (e.g. `typeof x === 'object'` or `expect(x instanceof Object).toBe(true)`). It fires because vitest's dedicated `toBeObject()` matcher expresses the intent directly.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vitest/prefer_to_be_object.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the manual object check with `expect(x).toBeObject()`"],"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"}