{"record":{"id":"4b036724dc7941e5","repo":"oxc-project/oxc","slug":"the-arrow-function-in-the-callback-of-the-array-is","errorCode":null,"errorMessage":"The arrow function in the callback of the array is equivalent to `Boolean`. Replace the callback with `Boolean`.","messagePattern":"The arrow function in the callback of the array is equivalent to `Boolean`\\. Replace the callback with `Boolean`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs","lineNumber":20,"sourceCode":"    AstKind,\n    ast::{Argument, Expression, FormalParameters, FunctionBody, Statement, TSType},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::NodeId;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule, utils::get_first_parameter_name};\n\nfn function(span: Span, called_fn: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"The function is equivalent to `{called_fn}`. Call `{called_fn}` directly.\"\n    ))\n    .with_label(span)\n}\n\nfn array_callback(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"The arrow function in the callback of the array is equivalent to `Boolean`. Replace the callback with `Boolean`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferNativeCoercionFunctions;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Prefers built-in functions over custom ones with the same functionality.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// If a function is equivalent to [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt), [`Boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean), or [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), you should use the built-in one directly.\n    /// Wrapping the built-in in a function is moot.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs#L2-L38","documentation":"Diagnostic from the unicorn/prefer-native-coercion-functions lint rule. It fires when an array method's callback is an arrow function that merely coerces its argument to a boolean, e.g. `arr.filter(x => Boolean(x))`; the native `Boolean` function is behaviorally identical and can replace the callback directly. The flagged input is the callback arrow function. It is a lint suggestion, not a runtime error.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the callback with `Boolean`, e.g. `arr.filter(Boolean)`","Consider `arr.filter(x => !!x)` alternatives only if the rule allows; `Boolean` is the canonical fix","Apply the rule's auto-fix"],"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"}