{"record":{"id":"40e1bc1b46bda98f","repo":"oxc-project/oxc","slug":"bad-handler-name","errorCode":null,"errorMessage":"Bad handler name","messagePattern":"Bad handler name","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/react/jsx_handler_names.rs","lineNumber":28,"sourceCode":"    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::{CompactStr, Ident};\nuse schemars::{\n    JsonSchema, SchemaGenerator,\n    schema::{Schema, SchemaObject, SubschemaValidation},\n};\nuse serde_json::Value;\n\nfn bad_handler_name_diagnostic(\n    span: Span,\n    prop_key: &str,\n    handler_name: Option<&str>,\n    handler_prefix: &str,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        if let Some(handler_name) = handler_name {\n            format!(\"Invalid handler name: {handler_name}\")\n        } else {\n            \"Bad handler name\".to_string()\n        },\n    )\n        .with_help(format!(\n            \"Handler function for {prop_key} prop key must be a camelCase name beginning with \\'{handler_prefix}\\' only\"\n        ))\n        .with_label(span)\n}\n\nfn bad_handler_prop_name_diagnostic(\n    span: Span,\n    prop_key: &str,\n    prop_value: Option<&str>,\n    handler_prop_prefix: &str,\n) -> OxcDiagnostic {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/jsx_handler_names.rs#L10-L46","documentation":"Fallback message from the same react/jsx-handler-names rule, emitted when the prop key is an event-handler prop (on*) but no handler name could be extracted from the value (handler_name is None). Per the implementation this only happens for arrow functions when checkInlineFunction is enabled and get_event_handler_name_from_arrow_function returns None: the arrow has a block body (e.g. () => { handleChange() }) or its single-expression body is not an identifier/member-expression call. The diagnostic labels the arrow function body span.","triggerScenarios":"Configuration { \"checkInlineFunction\": true } (plus checkLocalVariables: true, or a member-expression callee) combined with an on* prop whose value is an arrow function with a block body: <TestComponent onChange={() => { handleChange() }} />, or an expression-body arrow whose callee is not extractable (e.g. () => (fn || fallback)()). The rule cannot determine a name, so it reports the generic 'Bad handler name' with the requirement that it begin with the handler prefix.","commonSituations":"Porting an .eslintrc with checkInlineFunction/checkLocalVariables turned on to oxlint; codebases that inline multi-statement handlers in JSX; refactorings that changed a simple call arrow into a block-body arrow.","solutions":["Rewrite the inline handler as a single expression calling a properly named method: onChange={() => this.handleChange()}","Extract the block-bodied handler to a named handle-prefixed method/variable and pass it directly: onChange={this.handleChange}","Leave checkInlineFunction at its default false so inline arrow functions are not checked","Disable the rule if inline handler naming is not enforced on the team"],"exampleFix":"// before (checkInlineFunction: true)\n<TestComponent onChange={() => { doSomethingOnChange(); }} />\n\n// after\n<TestComponent onChange={() => this.handleChange()} />","handlingStrategy":"validation","validationCode":"# check only inline-function handler naming\nnpx oxlint -D react/jsx-handler-names src/  # with checkInlineFunction enabled in .oxlintrc.json","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer passing named methods (onChange={this.handleChange}) over block-bodied inline arrows","Keep inline handlers as single expression calls so the rule can extract and validate a name","Leave checkInlineFunction false unless the team explicitly wants inline handlers policed"],"tags":["react","jsx","naming-convention","event-handler","arrow-function","oxlint","lint"],"backgroundTag":"react-event-handler-naming","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"}