{"record":{"id":"a402b386f5711c73","repo":"oxc-project/oxc","slug":"expected-expression-to-be-used","errorCode":null,"errorMessage":"Expected expression to be used","messagePattern":"Expected expression to be used","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_unused_expressions.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{ChainElement, Expression, UnaryOperator},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\nuse serde_json::Value;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_unused_expressions_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Expected expression to be used\")\n        .with_help(\"Consider using this expression or removing it\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct NoUnusedExpressions(Box<NoUnusedExpressionsConfig>);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoUnusedExpressionsConfig {\n    /// When set to `true`, allows short circuit evaluations in expressions.\n    allow_short_circuit: bool,\n    /// When set to `true`, allows ternary operators in expressions.\n    allow_ternary: bool,\n    /// When set to `true`, allows tagged template literals in expressions.\n    allow_tagged_templates: bool,\n    /// When set to `true`, enforces the rule for unused JSX expressions also.\n    #[serde(rename = \"enforceForJSX\")]","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_unused_expressions.rs#L1-L37","documentation":"Diagnostic from oxlint's no-unused-expressions rule. An expression statement that only computes and discards a value has no effect and usually hides a missing call, assignment, or cast. Options: allowShortCircuit (a && b()), allowTernary (a ? b() : c()), allowTaggedTemplates, enforceForJSX, and ignoreDirectives for directive prologues.","triggerScenarios":"Set<number>; as a bare statement; 1 as number; window!; a + b; isReady && bootstrap(); without allowShortCircuit; cond ? f() : g(); without allowTernary.","commonSituations":"Guard-style short-circuit calls in a codebase where the options are off; leftover probe expressions from debugging; non-null assertions and type casts used as statements.","solutions":["Delete the statement or give it an effect (call it, assign it, export it).","Enable \"allowShortCircuit\": true for a && b() style and \"allowTernary\": true for side-effectful ternaries in .oxlintrc.json.","Convert the ternary to if/else when you do not want to relax the rule.","Wrap intended template tags with \"allowTaggedTemplates\": true (e.g. gql`...`)."],"exampleFix":"// before\nisReady && bootstrap();\n// after\nif (isReady) bootstrap();\n// or .oxlintrc.json: \"no-unused-expressions\": [\"error\", { \"allowShortCircuit\": true }]","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write side effects as statements: if/else instead of bare ternaries or short-circuit chains.","If your team relies on a && b() guards, set \"allowShortCircuit\": true once in .oxlintrc.json instead of sprinkling disables.","Delete probe expressions from debugging sessions before committing."],"tags":["eslint","oxlint","expressions","side-effects","style"],"backgroundTag":"unused-expression-statement","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"}