{"record":{"id":"40eaeb6df3f75690","repo":"oxc-project/oxc","slug":"unary-operator-operator-used","errorCode":null,"errorMessage":"Unary operator '{operator}' used.","messagePattern":"Unary operator '(.+?)' used\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_plusplus.rs","lineNumber":15,"sourceCode":"use oxc_ast::{AstKind, ast::UpdateOperator};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_plusplus_diagnostic(span: Span, operator: UpdateOperator) -> OxcDiagnostic {\n    let diagnostic = OxcDiagnostic::warn(format!(\n        \"Unary operator '{operator}' used.\",\n        operator = operator.as_str()\n    ))\n    .with_label(span);\n\n    match operator {\n        UpdateOperator::Increment => {\n            diagnostic.with_help(\"Use the assignment operator `+=` instead.\")\n        }\n        UpdateOperator::Decrement => {\n            diagnostic.with_help(\"Use the assignment operator `-=` instead.\")\n        }\n    }\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoPlusplus {","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_plusplus.rs#L1-L33","documentation":"Lint diagnostic from eslint/no-plusplus: the ++ or -- unary update operator was used (the operator name is interpolated into the message). The rule discourages them because pre/post increment semantics cause off-by-one bugs, especially inside expressions; the help suggests the compound-assignment form.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/no_plusplus.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use compound assignment: i += 1 or i -= 1","Enable allowForLoopAfterthoughts if ++ in for-loop updates is acceptable"],"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-14T05:17:10.506Z"}