Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,34 @@ pub struct ArrayCallbackReturn {

declare_oxc_lint!(
/// ### What it does
///
/// Enforce return statements in callbacks of array methods
///
/// ### Why is this bad?
///
/// Array has several methods for filtering, mapping, and folding.
/// If we forget to write return statement in a callback of those, it’s probably a mistake.
/// If you don’t want to use a return or don’t need the returned results,
/// consider using .forEach instead.
///
/// ### Example
///
/// Examples of **incorrect** code for this rule:
///
/// ```javascript
/// let foo = [1, 2, 3, 4];
/// foo.map((a) => {
/// console.log(a)
/// });
/// ```
///
/// Examples of **correct** code for this rule:
///
/// ```javascript
/// let foo = [1, 2, 3, 4];
/// foo.map((a) => {
/// console.log(a)
/// return a
/// });
/// ```
ArrayCallbackReturn,
Expand Down
Loading