diff --git a/.changeset/add-check-for-each-option.md b/.changeset/add-check-for-each-option.md new file mode 100644 index 000000000000..86837eb54638 --- /dev/null +++ b/.changeset/add-check-for-each-option.md @@ -0,0 +1,11 @@ +--- +"@biomejs/biome": patch +--- + +Added the `checkForEach` option to the `useIterableCallbackReturn` rule. + +When `checkForEach` is `true`, the rule reports when `forEach` callbacks return a value. When `false` (the default), `forEach` callbacks are not checked. + +This aligns with ESLint's `array-callback-return` rule behavior where `forEach` checking is opt-in. + +**Breaking change:** Previously, `forEach` was always checked. Users who want the previous behavior should set `checkForEach: true` in their configuration. diff --git a/crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs b/crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs index 6ce5644d2b9f..ead20c2c00f2 100644 --- a/crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs +++ b/crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs @@ -45,7 +45,15 @@ declare_lint_rule! { /// - `toSorted` /// — `from` (when called on `Array`) /// - /// A return value is disallowed in the method `forEach`. + /// When `checkForEach` is enabled, a return value is disallowed in the method `forEach`. + /// + /// ## Options + /// + /// ### checkForEach + /// + /// If `true`, also check that callbacks to `forEach` do not return a value. + /// + /// Default: `false` /// /// ## Examples /// @@ -57,12 +65,6 @@ declare_lint_rule! { /// }); /// ``` /// - /// ```js,expect_diagnostic - /// [].forEach(() => { - /// return 1; // Should not return a value - /// }); - /// ``` - /// /// ### Valid /// /// ```js @@ -72,14 +74,11 @@ declare_lint_rule! { /// ``` /// /// ```js + /// // By default, forEach callbacks may return a value /// [].forEach(() => { - /// // No return value, which is correct + /// return 1; /// }); /// ``` - /// - /// ```js - /// [].forEach(() => void null); // Void return value, which doesn't trigger the rule - /// ``` pub UseIterableCallbackReturn { version: "2.0.0", name: "useIterableCallbackReturn", @@ -130,6 +129,11 @@ impl Rule for UseIterableCallbackReturn { let method_config = ITERABLE_METHOD_INFOS.get(member_name.text_trimmed())?; + // Skip forEach checks if checkForEach option is false + if member_name.text_trimmed() == "forEach" && !ctx.options().check_for_each() { + return None; + } + let arg_position = argument_list .elements() .position(|arg| arg.node.is_ok() && arg.node.unwrap().syntax().eq(&cfg.node))?; diff --git a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js index 7083a2bef677..cad8ae90414f 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js +++ b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js @@ -1,32 +1,3 @@ -[].forEach((a) => { - return a.fn(); -}); -[].forEach(function(a) { - return a.fn(); -}); -[].forEach((a) => { - if (a) { - return a.fn(); - } -}); -[].forEach((a) => { - if (a) { - return; - } - return a.fn(); -}); -[].forEach((a) => { - if (a) { - return; - } - return a.fn(); -}); -[].forEach((a) => { - if (a) { - throw new Error(); - } - return a.fn(); -}); Array.from([], () => {}); Array.from([], function() {}); Array.from([], () => { diff --git a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js.snap b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js.snap index a8a1facd6b8f..f222df434e48 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js.snap @@ -4,35 +4,6 @@ expression: invalid.js --- # Input ```js -[].forEach((a) => { - return a.fn(); -}); -[].forEach(function(a) { - return a.fn(); -}); -[].forEach((a) => { - if (a) { - return a.fn(); - } -}); -[].forEach((a) => { - if (a) { - return; - } - return a.fn(); -}); -[].forEach((a) => { - if (a) { - return; - } - return a.fn(); -}); -[].forEach((a) => { - if (a) { - throw new Error(); - } - return a.fn(); -}); Array.from([], () => {}); Array.from([], function() {}); Array.from([], () => { @@ -238,168 +209,14 @@ Array.from([], (a) => void a.fn()); # Diagnostics ``` -invalid.js:1:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This callback passed to forEach() iterable method should not return a value. - - > 1 │ [].forEach((a) => { - │ ^^^^^^^ - 2 │ return a.fn(); - 3 │ }); - - i Either remove this return or remove the returned value. - - > 1 │ [].forEach((a) => { - │ - > 2 │ return a.fn(); - │ ^^^^^^^ - 3 │ }); - 4 │ [].forEach(function(a) { - - -``` - -``` -invalid.js:4:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This callback passed to forEach() iterable method should not return a value. - - 2 │ return a.fn(); - 3 │ }); - > 4 │ [].forEach(function(a) { - │ ^^^^^^^ - 5 │ return a.fn(); - 6 │ }); - - i Either remove this return or remove the returned value. - - 2 │ return a.fn(); - 3 │ }); - > 4 │ [].forEach(function(a) { - │ - > 5 │ return a.fn(); - │ ^^^^^^^ - 6 │ }); - 7 │ [].forEach((a) => { - - -``` - -``` -invalid.js:7:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This callback passed to forEach() iterable method should not return a value. - - 5 │ return a.fn(); - 6 │ }); - > 7 │ [].forEach((a) => { - │ ^^^^^^^ - 8 │ if (a) { - 9 │ return a.fn(); - - i Either remove this return or remove the returned value. - - 6 │ }); - 7 │ [].forEach((a) => { - > 8 │ if (a) { - │ - > 9 │ return a.fn(); - │ ^^^^^^^ - 10 │ } - 11 │ }); - - -``` - -``` -invalid.js:12:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This callback passed to forEach() iterable method should not return a value. - - 10 │ } - 11 │ }); - > 12 │ [].forEach((a) => { - │ ^^^^^^^ - 13 │ if (a) { - 14 │ return; - - i Either remove this return or remove the returned value. - - 13 │ if (a) { - 14 │ return; - > 15 │ } - │ - > 16 │ return a.fn(); - │ ^^^^^^^ - 17 │ }); - 18 │ [].forEach((a) => { - - -``` - -``` -invalid.js:18:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This callback passed to forEach() iterable method should not return a value. - - 16 │ return a.fn(); - 17 │ }); - > 18 │ [].forEach((a) => { - │ ^^^^^^^ - 19 │ if (a) { - 20 │ return; - - i Either remove this return or remove the returned value. - - 19 │ if (a) { - 20 │ return; - > 21 │ } - │ - > 22 │ return a.fn(); - │ ^^^^^^^ - 23 │ }); - 24 │ [].forEach((a) => { - - -``` - -``` -invalid.js:24:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This callback passed to forEach() iterable method should not return a value. - - 22 │ return a.fn(); - 23 │ }); - > 24 │ [].forEach((a) => { - │ ^^^^^^^ - 25 │ if (a) { - 26 │ throw new Error(); - - i Either remove this return or remove the returned value. - - 25 │ if (a) { - 26 │ throw new Error(); - > 27 │ } - │ - > 28 │ return a.fn(); - │ ^^^^^^^ - 29 │ }); - 30 │ Array.from([], () => {}); - - -``` - -``` -invalid.js:30:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:1:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to Array.from() method should always return a value. - 28 │ return a.fn(); - 29 │ }); - > 30 │ Array.from([], () => {}); - │ ^^^^ - 31 │ Array.from([], function() {}); - 32 │ Array.from([], () => { + > 1 │ Array.from([], () => {}); + │ ^^^^ + 2 │ Array.from([], function() {}); + 3 │ Array.from([], () => { i Add a return with a value to this callback. @@ -407,16 +224,15 @@ invalid.js:30:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:31:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:2:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to Array.from() method should always return a value. - 29 │ }); - 30 │ Array.from([], () => {}); - > 31 │ Array.from([], function() {}); - │ ^^^^ - 32 │ Array.from([], () => { - 33 │ return; + 1 │ Array.from([], () => {}); + > 2 │ Array.from([], function() {}); + │ ^^^^ + 3 │ Array.from([], () => { + 4 │ return; i Add a return with a value to this callback. @@ -424,16 +240,16 @@ invalid.js:31:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:32:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:3:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to Array.from() method should always return a value. - 30 │ Array.from([], () => {}); - 31 │ Array.from([], function() {}); - > 32 │ Array.from([], () => { - │ ^^^^ - 33 │ return; - 34 │ }); + 1 │ Array.from([], () => {}); + 2 │ Array.from([], function() {}); + > 3 │ Array.from([], () => { + │ ^^^^ + 4 │ return; + 5 │ }); i Add a return with a value to this callback. @@ -441,16 +257,16 @@ invalid.js:32:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:35:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:6:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to Array.from() method should always return a value. - 33 │ return; - 34 │ }); - > 35 │ Array.from([], function() { - │ ^^^^ - 36 │ return; - 37 │ }); + 4 │ return; + 5 │ }); + > 6 │ Array.from([], function() { + │ ^^^^ + 7 │ return; + 8 │ }); i Add a return with a value to this callback. @@ -458,16 +274,16 @@ invalid.js:35:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:38:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:9:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to Array.from() method should always return a value. - 36 │ return; - 37 │ }); - > 38 │ Array.from([], () => void null); + 7 │ return; + 8 │ }); + > 9 │ Array.from([], () => void null); │ ^^^^ - 39 │ Array.from([], (a) => void a.fn()); - 40 │ [].every(() => { + 10 │ Array.from([], (a) => void a.fn()); + 11 │ [].every(() => { i Add a return with a value to this callback. @@ -475,16 +291,16 @@ invalid.js:38:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:39:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:10:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to Array.from() method should always return a value. - 37 │ }); - 38 │ Array.from([], () => void null); - > 39 │ Array.from([], (a) => void a.fn()); + 8 │ }); + 9 │ Array.from([], () => void null); + > 10 │ Array.from([], (a) => void a.fn()); │ ^^^^ - 40 │ [].every(() => { - 41 │ return; + 11 │ [].every(() => { + 12 │ return; i Add a return with a value to this callback. @@ -492,16 +308,16 @@ invalid.js:39:7 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:40:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:11:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 38 │ Array.from([], () => void null); - 39 │ Array.from([], (a) => void a.fn()); - > 40 │ [].every(() => { + 9 │ Array.from([], () => void null); + 10 │ Array.from([], (a) => void a.fn()); + > 11 │ [].every(() => { │ ^^^^^ - 41 │ return; - 42 │ }); + 12 │ return; + 13 │ }); i Add a return with a value to this callback. @@ -509,16 +325,16 @@ invalid.js:40:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:43:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:14:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 41 │ return; - 42 │ }); - > 43 │ [].every(function() { + 12 │ return; + 13 │ }); + > 14 │ [].every(function() { │ ^^^^^ - 44 │ return; - 45 │ }); + 15 │ return; + 16 │ }); i Add a return with a value to this callback. @@ -526,16 +342,16 @@ invalid.js:43:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:46:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:17:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 44 │ return; - 45 │ }); - > 46 │ [].every(() => {}); + 15 │ return; + 16 │ }); + > 17 │ [].every(() => {}); │ ^^^^^ - 47 │ [].every(function() {}); - 48 │ [].every(() => { + 18 │ [].every(function() {}); + 19 │ [].every(() => { i Add a return with a value to this callback. @@ -543,16 +359,16 @@ invalid.js:46:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:47:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:18:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 45 │ }); - 46 │ [].every(() => {}); - > 47 │ [].every(function() {}); + 16 │ }); + 17 │ [].every(() => {}); + > 18 │ [].every(function() {}); │ ^^^^^ - 48 │ [].every(() => { - 49 │ try { + 19 │ [].every(() => { + 20 │ try { i Add a return with a value to this callback. @@ -560,16 +376,16 @@ invalid.js:47:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:48:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:19:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 46 │ [].every(() => {}); - 47 │ [].every(function() {}); - > 48 │ [].every(() => { + 17 │ [].every(() => {}); + 18 │ [].every(function() {}); + > 19 │ [].every(() => { │ ^^^^^ - 49 │ try { - 50 │ // ok + 20 │ try { + 21 │ // ok i Add a return with a value to this callback. @@ -577,16 +393,16 @@ invalid.js:48:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:55:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:26:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 53 │ } - 54 │ }); - > 55 │ [].every(() => { + 24 │ } + 25 │ }); + > 26 │ [].every(() => { │ ^^^^^ - 56 │ try { - 57 │ // ok + 27 │ try { + 28 │ // ok i Add a return with a value to this callback. @@ -594,16 +410,16 @@ invalid.js:55:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:64:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:35:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 62 │ } - 63 │ }); - > 64 │ [].every(() => { + 33 │ } + 34 │ }); + > 35 │ [].every(() => { │ ^^^^^ - 65 │ try { - 66 │ return true; + 36 │ try { + 37 │ return true; i Add missing return statements so that this callback returns a value on all execution paths. @@ -611,16 +427,16 @@ invalid.js:64:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:87:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:58:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 85 │ } finally {} - 86 │ }); - > 87 │ [].every(() => void null); + 56 │ } finally {} + 57 │ }); + > 58 │ [].every(() => void null); │ ^^^^^ - 88 │ [].every((a) => void a.fn()); - 89 │ [].filter(() => { + 59 │ [].every((a) => void a.fn()); + 60 │ [].filter(() => { i Add a return with a value to this callback. @@ -628,16 +444,16 @@ invalid.js:87:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:88:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:59:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to every() iterable method should always return a value. - 86 │ }); - 87 │ [].every(() => void null); - > 88 │ [].every((a) => void a.fn()); + 57 │ }); + 58 │ [].every(() => void null); + > 59 │ [].every((a) => void a.fn()); │ ^^^^^ - 89 │ [].filter(() => { - 90 │ return; + 60 │ [].filter(() => { + 61 │ return; i Add a return with a value to this callback. @@ -645,16 +461,16 @@ invalid.js:88:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:89:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:60:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to filter() iterable method should always return a value. - 87 │ [].every(() => void null); - 88 │ [].every((a) => void a.fn()); - > 89 │ [].filter(() => { + 58 │ [].every(() => void null); + 59 │ [].every((a) => void a.fn()); + > 60 │ [].filter(() => { │ ^^^^^^ - 90 │ return; - 91 │ }); + 61 │ return; + 62 │ }); i Add a return with a value to this callback. @@ -662,16 +478,16 @@ invalid.js:89:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:92:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:63:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to filter() iterable method should always return a value. - 90 │ return; - 91 │ }); - > 92 │ [].filter(function() { + 61 │ return; + 62 │ }); + > 63 │ [].filter(function() { │ ^^^^^^ - 93 │ return; - 94 │ }); + 64 │ return; + 65 │ }); i Add a return with a value to this callback. @@ -679,16 +495,16 @@ invalid.js:92:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:95:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:66:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to filter() iterable method should always return a value. - 93 │ return; - 94 │ }); - > 95 │ [].filter(() => {}); + 64 │ return; + 65 │ }); + > 66 │ [].filter(() => {}); │ ^^^^^^ - 96 │ [].filter(function() {}); - 97 │ [].filter(() => void null); + 67 │ [].filter(function() {}); + 68 │ [].filter(() => void null); i Add a return with a value to this callback. @@ -696,16 +512,16 @@ invalid.js:95:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:96:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:67:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to filter() iterable method should always return a value. - 94 │ }); - 95 │ [].filter(() => {}); - > 96 │ [].filter(function() {}); + 65 │ }); + 66 │ [].filter(() => {}); + > 67 │ [].filter(function() {}); │ ^^^^^^ - 97 │ [].filter(() => void null); - 98 │ [].filter((a) => void a.fn()); + 68 │ [].filter(() => void null); + 69 │ [].filter((a) => void a.fn()); i Add a return with a value to this callback. @@ -713,16 +529,16 @@ invalid.js:96:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:97:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:68:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to filter() iterable method should always return a value. - 95 │ [].filter(() => {}); - 96 │ [].filter(function() {}); - > 97 │ [].filter(() => void null); + 66 │ [].filter(() => {}); + 67 │ [].filter(function() {}); + > 68 │ [].filter(() => void null); │ ^^^^^^ - 98 │ [].filter((a) => void a.fn()); - 99 │ [].find(() => { + 69 │ [].filter((a) => void a.fn()); + 70 │ [].find(() => { i Add a return with a value to this callback. @@ -730,16 +546,16 @@ invalid.js:97:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:98:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:69:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to filter() iterable method should always return a value. - 96 │ [].filter(function() {}); - 97 │ [].filter(() => void null); - > 98 │ [].filter((a) => void a.fn()); - │ ^^^^^^ - 99 │ [].find(() => { - 100 │ return; + 67 │ [].filter(function() {}); + 68 │ [].filter(() => void null); + > 69 │ [].filter((a) => void a.fn()); + │ ^^^^^^ + 70 │ [].find(() => { + 71 │ return; i Add a return with a value to this callback. @@ -747,16 +563,16 @@ invalid.js:98:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:99:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:70:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to find() iterable method should always return a value. - 97 │ [].filter(() => void null); - 98 │ [].filter((a) => void a.fn()); - > 99 │ [].find(() => { - │ ^^^^ - 100 │ return; - 101 │ }); + 68 │ [].filter(() => void null); + 69 │ [].filter((a) => void a.fn()); + > 70 │ [].find(() => { + │ ^^^^ + 71 │ return; + 72 │ }); i Add a return with a value to this callback. @@ -764,16 +580,16 @@ invalid.js:99:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:102:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:73:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to find() iterable method should always return a value. - 100 │ return; - 101 │ }); - > 102 │ [].find(function() { - │ ^^^^ - 103 │ return; - 104 │ }); + 71 │ return; + 72 │ }); + > 73 │ [].find(function() { + │ ^^^^ + 74 │ return; + 75 │ }); i Add a return with a value to this callback. @@ -781,16 +597,16 @@ invalid.js:102:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:105:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:76:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to find() iterable method should always return a value. - 103 │ return; - 104 │ }); - > 105 │ [].find(() => {}); - │ ^^^^ - 106 │ [].find(function() {}); - 107 │ [].find(() => void null); + 74 │ return; + 75 │ }); + > 76 │ [].find(() => {}); + │ ^^^^ + 77 │ [].find(function() {}); + 78 │ [].find(() => void null); i Add a return with a value to this callback. @@ -798,16 +614,16 @@ invalid.js:105:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:106:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:77:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to find() iterable method should always return a value. - 104 │ }); - 105 │ [].find(() => {}); - > 106 │ [].find(function() {}); - │ ^^^^ - 107 │ [].find(() => void null); - 108 │ [].find((a) => void a.fn()); + 75 │ }); + 76 │ [].find(() => {}); + > 77 │ [].find(function() {}); + │ ^^^^ + 78 │ [].find(() => void null); + 79 │ [].find((a) => void a.fn()); i Add a return with a value to this callback. @@ -815,16 +631,16 @@ invalid.js:106:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:107:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:78:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to find() iterable method should always return a value. - 105 │ [].find(() => {}); - 106 │ [].find(function() {}); - > 107 │ [].find(() => void null); - │ ^^^^ - 108 │ [].find((a) => void a.fn()); - 109 │ [].findIndex(() => { + 76 │ [].find(() => {}); + 77 │ [].find(function() {}); + > 78 │ [].find(() => void null); + │ ^^^^ + 79 │ [].find((a) => void a.fn()); + 80 │ [].findIndex(() => { i Add a return with a value to this callback. @@ -832,16 +648,16 @@ invalid.js:107:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:108:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:79:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to find() iterable method should always return a value. - 106 │ [].find(function() {}); - 107 │ [].find(() => void null); - > 108 │ [].find((a) => void a.fn()); - │ ^^^^ - 109 │ [].findIndex(() => { - 110 │ return; + 77 │ [].find(function() {}); + 78 │ [].find(() => void null); + > 79 │ [].find((a) => void a.fn()); + │ ^^^^ + 80 │ [].findIndex(() => { + 81 │ return; i Add a return with a value to this callback. @@ -849,16 +665,16 @@ invalid.js:108:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:109:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:80:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findIndex() iterable method should always return a value. - 107 │ [].find(() => void null); - 108 │ [].find((a) => void a.fn()); - > 109 │ [].findIndex(() => { - │ ^^^^^^^^^ - 110 │ return; - 111 │ }); + 78 │ [].find(() => void null); + 79 │ [].find((a) => void a.fn()); + > 80 │ [].findIndex(() => { + │ ^^^^^^^^^ + 81 │ return; + 82 │ }); i Add a return with a value to this callback. @@ -866,16 +682,16 @@ invalid.js:109:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:112:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:83:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findIndex() iterable method should always return a value. - 110 │ return; - 111 │ }); - > 112 │ [].findIndex(function() { - │ ^^^^^^^^^ - 113 │ return; - 114 │ }); + 81 │ return; + 82 │ }); + > 83 │ [].findIndex(function() { + │ ^^^^^^^^^ + 84 │ return; + 85 │ }); i Add a return with a value to this callback. @@ -883,16 +699,16 @@ invalid.js:112:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:115:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:86:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findIndex() iterable method should always return a value. - 113 │ return; - 114 │ }); - > 115 │ [].findIndex(() => {}); - │ ^^^^^^^^^ - 116 │ [].findIndex(function() {}); - 117 │ [].findIndex(() => void null); + 84 │ return; + 85 │ }); + > 86 │ [].findIndex(() => {}); + │ ^^^^^^^^^ + 87 │ [].findIndex(function() {}); + 88 │ [].findIndex(() => void null); i Add a return with a value to this callback. @@ -900,16 +716,16 @@ invalid.js:115:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:116:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:87:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findIndex() iterable method should always return a value. - 114 │ }); - 115 │ [].findIndex(() => {}); - > 116 │ [].findIndex(function() {}); - │ ^^^^^^^^^ - 117 │ [].findIndex(() => void null); - 118 │ [].findIndex((a) => void a.fn()); + 85 │ }); + 86 │ [].findIndex(() => {}); + > 87 │ [].findIndex(function() {}); + │ ^^^^^^^^^ + 88 │ [].findIndex(() => void null); + 89 │ [].findIndex((a) => void a.fn()); i Add a return with a value to this callback. @@ -917,16 +733,16 @@ invalid.js:116:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:117:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:88:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findIndex() iterable method should always return a value. - 115 │ [].findIndex(() => {}); - 116 │ [].findIndex(function() {}); - > 117 │ [].findIndex(() => void null); - │ ^^^^^^^^^ - 118 │ [].findIndex((a) => void a.fn()); - 119 │ [].findLast(() => { + 86 │ [].findIndex(() => {}); + 87 │ [].findIndex(function() {}); + > 88 │ [].findIndex(() => void null); + │ ^^^^^^^^^ + 89 │ [].findIndex((a) => void a.fn()); + 90 │ [].findLast(() => { i Add a return with a value to this callback. @@ -934,16 +750,16 @@ invalid.js:117:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:118:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:89:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findIndex() iterable method should always return a value. - 116 │ [].findIndex(function() {}); - 117 │ [].findIndex(() => void null); - > 118 │ [].findIndex((a) => void a.fn()); - │ ^^^^^^^^^ - 119 │ [].findLast(() => { - 120 │ return; + 87 │ [].findIndex(function() {}); + 88 │ [].findIndex(() => void null); + > 89 │ [].findIndex((a) => void a.fn()); + │ ^^^^^^^^^ + 90 │ [].findLast(() => { + 91 │ return; i Add a return with a value to this callback. @@ -951,16 +767,16 @@ invalid.js:118:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:119:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:90:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLast() iterable method should always return a value. - 117 │ [].findIndex(() => void null); - 118 │ [].findIndex((a) => void a.fn()); - > 119 │ [].findLast(() => { - │ ^^^^^^^^ - 120 │ return; - 121 │ }); + 88 │ [].findIndex(() => void null); + 89 │ [].findIndex((a) => void a.fn()); + > 90 │ [].findLast(() => { + │ ^^^^^^^^ + 91 │ return; + 92 │ }); i Add a return with a value to this callback. @@ -968,16 +784,16 @@ invalid.js:119:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:122:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:93:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLast() iterable method should always return a value. - 120 │ return; - 121 │ }); - > 122 │ [].findLast(function() { - │ ^^^^^^^^ - 123 │ return; - 124 │ }); + 91 │ return; + 92 │ }); + > 93 │ [].findLast(function() { + │ ^^^^^^^^ + 94 │ return; + 95 │ }); i Add a return with a value to this callback. @@ -985,16 +801,16 @@ invalid.js:122:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:125:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:96:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLast() iterable method should always return a value. - 123 │ return; - 124 │ }); - > 125 │ [].findLast(() => {}); - │ ^^^^^^^^ - 126 │ [].findLast(function() {}); - 127 │ [].findLast(() => void null); + 94 │ return; + 95 │ }); + > 96 │ [].findLast(() => {}); + │ ^^^^^^^^ + 97 │ [].findLast(function() {}); + 98 │ [].findLast(() => void null); i Add a return with a value to this callback. @@ -1002,16 +818,16 @@ invalid.js:125:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:126:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:97:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLast() iterable method should always return a value. - 124 │ }); - 125 │ [].findLast(() => {}); - > 126 │ [].findLast(function() {}); - │ ^^^^^^^^ - 127 │ [].findLast(() => void null); - 128 │ [].findLast((a) => void a.fn()); + 95 │ }); + 96 │ [].findLast(() => {}); + > 97 │ [].findLast(function() {}); + │ ^^^^^^^^ + 98 │ [].findLast(() => void null); + 99 │ [].findLast((a) => void a.fn()); i Add a return with a value to this callback. @@ -1019,16 +835,16 @@ invalid.js:126:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:127:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:98:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLast() iterable method should always return a value. - 125 │ [].findLast(() => {}); - 126 │ [].findLast(function() {}); - > 127 │ [].findLast(() => void null); + 96 │ [].findLast(() => {}); + 97 │ [].findLast(function() {}); + > 98 │ [].findLast(() => void null); │ ^^^^^^^^ - 128 │ [].findLast((a) => void a.fn()); - 129 │ [].findLastIndex(() => { + 99 │ [].findLast((a) => void a.fn()); + 100 │ [].findLastIndex(() => { i Add a return with a value to this callback. @@ -1036,16 +852,16 @@ invalid.js:127:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:128:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:99:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLast() iterable method should always return a value. - 126 │ [].findLast(function() {}); - 127 │ [].findLast(() => void null); - > 128 │ [].findLast((a) => void a.fn()); + 97 │ [].findLast(function() {}); + 98 │ [].findLast(() => void null); + > 99 │ [].findLast((a) => void a.fn()); │ ^^^^^^^^ - 129 │ [].findLastIndex(() => { - 130 │ return; + 100 │ [].findLastIndex(() => { + 101 │ return; i Add a return with a value to this callback. @@ -1053,16 +869,16 @@ invalid.js:128:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:129:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:100:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLastIndex() iterable method should always return a value. - 127 │ [].findLast(() => void null); - 128 │ [].findLast((a) => void a.fn()); - > 129 │ [].findLastIndex(() => { + 98 │ [].findLast(() => void null); + 99 │ [].findLast((a) => void a.fn()); + > 100 │ [].findLastIndex(() => { │ ^^^^^^^^^^^^^ - 130 │ return; - 131 │ }); + 101 │ return; + 102 │ }); i Add a return with a value to this callback. @@ -1070,16 +886,16 @@ invalid.js:129:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:132:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:103:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLastIndex() iterable method should always return a value. - 130 │ return; - 131 │ }); - > 132 │ [].findLastIndex(function() { + 101 │ return; + 102 │ }); + > 103 │ [].findLastIndex(function() { │ ^^^^^^^^^^^^^ - 133 │ return; - 134 │ }); + 104 │ return; + 105 │ }); i Add a return with a value to this callback. @@ -1087,16 +903,16 @@ invalid.js:132:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:135:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:106:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLastIndex() iterable method should always return a value. - 133 │ return; - 134 │ }); - > 135 │ [].findLastIndex(() => {}); + 104 │ return; + 105 │ }); + > 106 │ [].findLastIndex(() => {}); │ ^^^^^^^^^^^^^ - 136 │ [].findLastIndex(function() {}); - 137 │ [].findLastIndex(() => void null); + 107 │ [].findLastIndex(function() {}); + 108 │ [].findLastIndex(() => void null); i Add a return with a value to this callback. @@ -1104,16 +920,16 @@ invalid.js:135:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:136:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:107:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLastIndex() iterable method should always return a value. - 134 │ }); - 135 │ [].findLastIndex(() => {}); - > 136 │ [].findLastIndex(function() {}); + 105 │ }); + 106 │ [].findLastIndex(() => {}); + > 107 │ [].findLastIndex(function() {}); │ ^^^^^^^^^^^^^ - 137 │ [].findLastIndex(() => void null); - 138 │ [].findLastIndex((a) => void a.fn()); + 108 │ [].findLastIndex(() => void null); + 109 │ [].findLastIndex((a) => void a.fn()); i Add a return with a value to this callback. @@ -1121,16 +937,16 @@ invalid.js:136:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:137:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:108:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLastIndex() iterable method should always return a value. - 135 │ [].findLastIndex(() => {}); - 136 │ [].findLastIndex(function() {}); - > 137 │ [].findLastIndex(() => void null); + 106 │ [].findLastIndex(() => {}); + 107 │ [].findLastIndex(function() {}); + > 108 │ [].findLastIndex(() => void null); │ ^^^^^^^^^^^^^ - 138 │ [].findLastIndex((a) => void a.fn()); - 139 │ [].some(() => { + 109 │ [].findLastIndex((a) => void a.fn()); + 110 │ [].some(() => { i Add a return with a value to this callback. @@ -1138,16 +954,16 @@ invalid.js:137:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:138:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:109:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to findLastIndex() iterable method should always return a value. - 136 │ [].findLastIndex(function() {}); - 137 │ [].findLastIndex(() => void null); - > 138 │ [].findLastIndex((a) => void a.fn()); + 107 │ [].findLastIndex(function() {}); + 108 │ [].findLastIndex(() => void null); + > 109 │ [].findLastIndex((a) => void a.fn()); │ ^^^^^^^^^^^^^ - 139 │ [].some(() => { - 140 │ return; + 110 │ [].some(() => { + 111 │ return; i Add a return with a value to this callback. @@ -1155,16 +971,16 @@ invalid.js:138:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:139:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:110:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to some() iterable method should always return a value. - 137 │ [].findLastIndex(() => void null); - 138 │ [].findLastIndex((a) => void a.fn()); - > 139 │ [].some(() => { + 108 │ [].findLastIndex(() => void null); + 109 │ [].findLastIndex((a) => void a.fn()); + > 110 │ [].some(() => { │ ^^^^ - 140 │ return; - 141 │ }); + 111 │ return; + 112 │ }); i Add a return with a value to this callback. @@ -1172,16 +988,16 @@ invalid.js:139:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:142:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:113:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to some() iterable method should always return a value. - 140 │ return; - 141 │ }); - > 142 │ [].some(function() { + 111 │ return; + 112 │ }); + > 113 │ [].some(function() { │ ^^^^ - 143 │ return; - 144 │ }); + 114 │ return; + 115 │ }); i Add a return with a value to this callback. @@ -1189,16 +1005,16 @@ invalid.js:142:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:145:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:116:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to some() iterable method should always return a value. - 143 │ return; - 144 │ }); - > 145 │ [].some(() => {}); + 114 │ return; + 115 │ }); + > 116 │ [].some(() => {}); │ ^^^^ - 146 │ [].some(function() {}); - 147 │ [].some(() => void null); + 117 │ [].some(function() {}); + 118 │ [].some(() => void null); i Add a return with a value to this callback. @@ -1206,16 +1022,16 @@ invalid.js:145:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:146:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:117:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to some() iterable method should always return a value. - 144 │ }); - 145 │ [].some(() => {}); - > 146 │ [].some(function() {}); + 115 │ }); + 116 │ [].some(() => {}); + > 117 │ [].some(function() {}); │ ^^^^ - 147 │ [].some(() => void null); - 148 │ [].some((a) => void a.fn()); + 118 │ [].some(() => void null); + 119 │ [].some((a) => void a.fn()); i Add a return with a value to this callback. @@ -1223,16 +1039,16 @@ invalid.js:146:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:147:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:118:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to some() iterable method should always return a value. - 145 │ [].some(() => {}); - 146 │ [].some(function() {}); - > 147 │ [].some(() => void null); + 116 │ [].some(() => {}); + 117 │ [].some(function() {}); + > 118 │ [].some(() => void null); │ ^^^^ - 148 │ [].some((a) => void a.fn()); - 149 │ [].flatMap(() => { + 119 │ [].some((a) => void a.fn()); + 120 │ [].flatMap(() => { i Add a return with a value to this callback. @@ -1240,16 +1056,16 @@ invalid.js:147:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:148:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:119:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to some() iterable method should always return a value. - 146 │ [].some(function() {}); - 147 │ [].some(() => void null); - > 148 │ [].some((a) => void a.fn()); + 117 │ [].some(function() {}); + 118 │ [].some(() => void null); + > 119 │ [].some((a) => void a.fn()); │ ^^^^ - 149 │ [].flatMap(() => { - 150 │ return; + 120 │ [].flatMap(() => { + 121 │ return; i Add a return with a value to this callback. @@ -1257,16 +1073,16 @@ invalid.js:148:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:149:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:120:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to flatMap() iterable method should always return a value. - 147 │ [].some(() => void null); - 148 │ [].some((a) => void a.fn()); - > 149 │ [].flatMap(() => { + 118 │ [].some(() => void null); + 119 │ [].some((a) => void a.fn()); + > 120 │ [].flatMap(() => { │ ^^^^^^^ - 150 │ return; - 151 │ }); + 121 │ return; + 122 │ }); i Add a return with a value to this callback. @@ -1274,16 +1090,16 @@ invalid.js:149:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:152:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:123:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to flatMap() iterable method should always return a value. - 150 │ return; - 151 │ }); - > 152 │ [].flatMap(function() { + 121 │ return; + 122 │ }); + > 123 │ [].flatMap(function() { │ ^^^^^^^ - 153 │ return; - 154 │ }); + 124 │ return; + 125 │ }); i Add a return with a value to this callback. @@ -1291,16 +1107,16 @@ invalid.js:152:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:155:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:126:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to flatMap() iterable method should always return a value. - 153 │ return; - 154 │ }); - > 155 │ [].flatMap(() => {}); + 124 │ return; + 125 │ }); + > 126 │ [].flatMap(() => {}); │ ^^^^^^^ - 156 │ [].flatMap(function() {}); - 157 │ [].flatMap(() => void null); + 127 │ [].flatMap(function() {}); + 128 │ [].flatMap(() => void null); i Add a return with a value to this callback. @@ -1308,16 +1124,16 @@ invalid.js:155:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:156:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:127:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to flatMap() iterable method should always return a value. - 154 │ }); - 155 │ [].flatMap(() => {}); - > 156 │ [].flatMap(function() {}); + 125 │ }); + 126 │ [].flatMap(() => {}); + > 127 │ [].flatMap(function() {}); │ ^^^^^^^ - 157 │ [].flatMap(() => void null); - 158 │ [].flatMap((a) => void a.fn()); + 128 │ [].flatMap(() => void null); + 129 │ [].flatMap((a) => void a.fn()); i Add a return with a value to this callback. @@ -1325,16 +1141,16 @@ invalid.js:156:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:157:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:128:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to flatMap() iterable method should always return a value. - 155 │ [].flatMap(() => {}); - 156 │ [].flatMap(function() {}); - > 157 │ [].flatMap(() => void null); + 126 │ [].flatMap(() => {}); + 127 │ [].flatMap(function() {}); + > 128 │ [].flatMap(() => void null); │ ^^^^^^^ - 158 │ [].flatMap((a) => void a.fn()); - 159 │ [].map(() => { + 129 │ [].flatMap((a) => void a.fn()); + 130 │ [].map(() => { i Add a return with a value to this callback. @@ -1342,16 +1158,16 @@ invalid.js:157:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:158:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:129:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to flatMap() iterable method should always return a value. - 156 │ [].flatMap(function() {}); - 157 │ [].flatMap(() => void null); - > 158 │ [].flatMap((a) => void a.fn()); + 127 │ [].flatMap(function() {}); + 128 │ [].flatMap(() => void null); + > 129 │ [].flatMap((a) => void a.fn()); │ ^^^^^^^ - 159 │ [].map(() => { - 160 │ return; + 130 │ [].map(() => { + 131 │ return; i Add a return with a value to this callback. @@ -1359,16 +1175,16 @@ invalid.js:158:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:159:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:130:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to map() iterable method should always return a value. - 157 │ [].flatMap(() => void null); - 158 │ [].flatMap((a) => void a.fn()); - > 159 │ [].map(() => { + 128 │ [].flatMap(() => void null); + 129 │ [].flatMap((a) => void a.fn()); + > 130 │ [].map(() => { │ ^^^ - 160 │ return; - 161 │ }); + 131 │ return; + 132 │ }); i Add a return with a value to this callback. @@ -1376,16 +1192,16 @@ invalid.js:159:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:162:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:133:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to map() iterable method should always return a value. - 160 │ return; - 161 │ }); - > 162 │ [].map(function() { + 131 │ return; + 132 │ }); + > 133 │ [].map(function() { │ ^^^ - 163 │ return; - 164 │ }); + 134 │ return; + 135 │ }); i Add a return with a value to this callback. @@ -1393,16 +1209,16 @@ invalid.js:162:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:165:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:136:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to map() iterable method should always return a value. - 163 │ return; - 164 │ }); - > 165 │ [].map(() => {}); + 134 │ return; + 135 │ }); + > 136 │ [].map(() => {}); │ ^^^ - 166 │ [].map(function() {}); - 167 │ [].map(() => void null); + 137 │ [].map(function() {}); + 138 │ [].map(() => void null); i Add a return with a value to this callback. @@ -1410,16 +1226,16 @@ invalid.js:165:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:166:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:137:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to map() iterable method should always return a value. - 164 │ }); - 165 │ [].map(() => {}); - > 166 │ [].map(function() {}); + 135 │ }); + 136 │ [].map(() => {}); + > 137 │ [].map(function() {}); │ ^^^ - 167 │ [].map(() => void null); - 168 │ [].map((a) => void a.fn()); + 138 │ [].map(() => void null); + 139 │ [].map((a) => void a.fn()); i Add a return with a value to this callback. @@ -1427,16 +1243,16 @@ invalid.js:166:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:167:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:138:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to map() iterable method should always return a value. - 165 │ [].map(() => {}); - 166 │ [].map(function() {}); - > 167 │ [].map(() => void null); + 136 │ [].map(() => {}); + 137 │ [].map(function() {}); + > 138 │ [].map(() => void null); │ ^^^ - 168 │ [].map((a) => void a.fn()); - 169 │ [].reduce((a, b) => { + 139 │ [].map((a) => void a.fn()); + 140 │ [].reduce((a, b) => { i Add a return with a value to this callback. @@ -1444,16 +1260,16 @@ invalid.js:167:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:168:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:139:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to map() iterable method should always return a value. - 166 │ [].map(function() {}); - 167 │ [].map(() => void null); - > 168 │ [].map((a) => void a.fn()); + 137 │ [].map(function() {}); + 138 │ [].map(() => void null); + > 139 │ [].map((a) => void a.fn()); │ ^^^ - 169 │ [].reduce((a, b) => { - 170 │ return; + 140 │ [].reduce((a, b) => { + 141 │ return; i Add a return with a value to this callback. @@ -1461,16 +1277,16 @@ invalid.js:168:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:169:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:140:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduce() iterable method should always return a value. - 167 │ [].map(() => void null); - 168 │ [].map((a) => void a.fn()); - > 169 │ [].reduce((a, b) => { + 138 │ [].map(() => void null); + 139 │ [].map((a) => void a.fn()); + > 140 │ [].reduce((a, b) => { │ ^^^^^^ - 170 │ return; - 171 │ }); + 141 │ return; + 142 │ }); i Add a return with a value to this callback. @@ -1478,16 +1294,16 @@ invalid.js:169:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:172:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:143:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduce() iterable method should always return a value. - 170 │ return; - 171 │ }); - > 172 │ [].reduce(function(a, b) { + 141 │ return; + 142 │ }); + > 143 │ [].reduce(function(a, b) { │ ^^^^^^ - 173 │ return; - 174 │ }); + 144 │ return; + 145 │ }); i Add a return with a value to this callback. @@ -1495,16 +1311,16 @@ invalid.js:172:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:175:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:146:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduce() iterable method should always return a value. - 173 │ return; - 174 │ }); - > 175 │ [].reduce((a, b) => {}); + 144 │ return; + 145 │ }); + > 146 │ [].reduce((a, b) => {}); │ ^^^^^^ - 176 │ [].reduce(function(a, b) {}); - 177 │ [].reduce(() => void null); + 147 │ [].reduce(function(a, b) {}); + 148 │ [].reduce(() => void null); i Add a return with a value to this callback. @@ -1512,16 +1328,16 @@ invalid.js:175:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:176:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:147:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduce() iterable method should always return a value. - 174 │ }); - 175 │ [].reduce((a, b) => {}); - > 176 │ [].reduce(function(a, b) {}); + 145 │ }); + 146 │ [].reduce((a, b) => {}); + > 147 │ [].reduce(function(a, b) {}); │ ^^^^^^ - 177 │ [].reduce(() => void null); - 178 │ [].reduce((a, b) => void a.fn()); + 148 │ [].reduce(() => void null); + 149 │ [].reduce((a, b) => void a.fn()); i Add a return with a value to this callback. @@ -1529,16 +1345,16 @@ invalid.js:176:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:177:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:148:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduce() iterable method should always return a value. - 175 │ [].reduce((a, b) => {}); - 176 │ [].reduce(function(a, b) {}); - > 177 │ [].reduce(() => void null); + 146 │ [].reduce((a, b) => {}); + 147 │ [].reduce(function(a, b) {}); + > 148 │ [].reduce(() => void null); │ ^^^^^^ - 178 │ [].reduce((a, b) => void a.fn()); - 179 │ [].reduceRight((a, b) => { + 149 │ [].reduce((a, b) => void a.fn()); + 150 │ [].reduceRight((a, b) => { i Add a return with a value to this callback. @@ -1546,16 +1362,16 @@ invalid.js:177:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:178:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:149:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduce() iterable method should always return a value. - 176 │ [].reduce(function(a, b) {}); - 177 │ [].reduce(() => void null); - > 178 │ [].reduce((a, b) => void a.fn()); + 147 │ [].reduce(function(a, b) {}); + 148 │ [].reduce(() => void null); + > 149 │ [].reduce((a, b) => void a.fn()); │ ^^^^^^ - 179 │ [].reduceRight((a, b) => { - 180 │ return; + 150 │ [].reduceRight((a, b) => { + 151 │ return; i Add a return with a value to this callback. @@ -1563,16 +1379,16 @@ invalid.js:178:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:179:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:150:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduceRight() iterable method should always return a value. - 177 │ [].reduce(() => void null); - 178 │ [].reduce((a, b) => void a.fn()); - > 179 │ [].reduceRight((a, b) => { + 148 │ [].reduce(() => void null); + 149 │ [].reduce((a, b) => void a.fn()); + > 150 │ [].reduceRight((a, b) => { │ ^^^^^^^^^^^ - 180 │ return; - 181 │ }); + 151 │ return; + 152 │ }); i Add a return with a value to this callback. @@ -1580,16 +1396,16 @@ invalid.js:179:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:182:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:153:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduceRight() iterable method should always return a value. - 180 │ return; - 181 │ }); - > 182 │ [].reduceRight(function(a, b) { + 151 │ return; + 152 │ }); + > 153 │ [].reduceRight(function(a, b) { │ ^^^^^^^^^^^ - 183 │ return; - 184 │ }); + 154 │ return; + 155 │ }); i Add a return with a value to this callback. @@ -1597,16 +1413,16 @@ invalid.js:182:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:185:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:156:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduceRight() iterable method should always return a value. - 183 │ return; - 184 │ }); - > 185 │ [].reduceRight((a, b) => {}); + 154 │ return; + 155 │ }); + > 156 │ [].reduceRight((a, b) => {}); │ ^^^^^^^^^^^ - 186 │ [].reduceRight(function(a, b) {}); - 187 │ [].reduceRight(() => void null); + 157 │ [].reduceRight(function(a, b) {}); + 158 │ [].reduceRight(() => void null); i Add a return with a value to this callback. @@ -1614,16 +1430,16 @@ invalid.js:185:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:186:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:157:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduceRight() iterable method should always return a value. - 184 │ }); - 185 │ [].reduceRight((a, b) => {}); - > 186 │ [].reduceRight(function(a, b) {}); + 155 │ }); + 156 │ [].reduceRight((a, b) => {}); + > 157 │ [].reduceRight(function(a, b) {}); │ ^^^^^^^^^^^ - 187 │ [].reduceRight(() => void null); - 188 │ [].reduceRight((a, b) => void a.fn()); + 158 │ [].reduceRight(() => void null); + 159 │ [].reduceRight((a, b) => void a.fn()); i Add a return with a value to this callback. @@ -1631,16 +1447,16 @@ invalid.js:186:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:187:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:158:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduceRight() iterable method should always return a value. - 185 │ [].reduceRight((a, b) => {}); - 186 │ [].reduceRight(function(a, b) {}); - > 187 │ [].reduceRight(() => void null); + 156 │ [].reduceRight((a, b) => {}); + 157 │ [].reduceRight(function(a, b) {}); + > 158 │ [].reduceRight(() => void null); │ ^^^^^^^^^^^ - 188 │ [].reduceRight((a, b) => void a.fn()); - 189 │ [].sort((a, b) => { + 159 │ [].reduceRight((a, b) => void a.fn()); + 160 │ [].sort((a, b) => { i Add a return with a value to this callback. @@ -1648,16 +1464,16 @@ invalid.js:187:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:188:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:159:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to reduceRight() iterable method should always return a value. - 186 │ [].reduceRight(function(a, b) {}); - 187 │ [].reduceRight(() => void null); - > 188 │ [].reduceRight((a, b) => void a.fn()); + 157 │ [].reduceRight(function(a, b) {}); + 158 │ [].reduceRight(() => void null); + > 159 │ [].reduceRight((a, b) => void a.fn()); │ ^^^^^^^^^^^ - 189 │ [].sort((a, b) => { - 190 │ return; + 160 │ [].sort((a, b) => { + 161 │ return; i Add a return with a value to this callback. @@ -1665,16 +1481,16 @@ invalid.js:188:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:189:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:160:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to sort() iterable method should always return a value. - 187 │ [].reduceRight(() => void null); - 188 │ [].reduceRight((a, b) => void a.fn()); - > 189 │ [].sort((a, b) => { + 158 │ [].reduceRight(() => void null); + 159 │ [].reduceRight((a, b) => void a.fn()); + > 160 │ [].sort((a, b) => { │ ^^^^ - 190 │ return; - 191 │ }); + 161 │ return; + 162 │ }); i Add a return with a value to this callback. @@ -1682,16 +1498,16 @@ invalid.js:189:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:192:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:163:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to sort() iterable method should always return a value. - 190 │ return; - 191 │ }); - > 192 │ [].sort(function(a, b) { + 161 │ return; + 162 │ }); + > 163 │ [].sort(function(a, b) { │ ^^^^ - 193 │ return; - 194 │ }); + 164 │ return; + 165 │ }); i Add a return with a value to this callback. @@ -1699,16 +1515,16 @@ invalid.js:192:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:195:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:166:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to sort() iterable method should always return a value. - 193 │ return; - 194 │ }); - > 195 │ [].sort((a, b) => {}); + 164 │ return; + 165 │ }); + > 166 │ [].sort((a, b) => {}); │ ^^^^ - 196 │ [].sort(function(a, b) {}); - 197 │ [].sort(() => void null); + 167 │ [].sort(function(a, b) {}); + 168 │ [].sort(() => void null); i Add a return with a value to this callback. @@ -1716,16 +1532,16 @@ invalid.js:195:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:196:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:167:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to sort() iterable method should always return a value. - 194 │ }); - 195 │ [].sort((a, b) => {}); - > 196 │ [].sort(function(a, b) {}); + 165 │ }); + 166 │ [].sort((a, b) => {}); + > 167 │ [].sort(function(a, b) {}); │ ^^^^ - 197 │ [].sort(() => void null); - 198 │ [].sort((a, b) => void a.fn()); + 168 │ [].sort(() => void null); + 169 │ [].sort((a, b) => void a.fn()); i Add a return with a value to this callback. @@ -1733,16 +1549,16 @@ invalid.js:196:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:197:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:168:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to sort() iterable method should always return a value. - 195 │ [].sort((a, b) => {}); - 196 │ [].sort(function(a, b) {}); - > 197 │ [].sort(() => void null); + 166 │ [].sort((a, b) => {}); + 167 │ [].sort(function(a, b) {}); + > 168 │ [].sort(() => void null); │ ^^^^ - 198 │ [].sort((a, b) => void a.fn()); - 199 │ [].toSorted((a, b) => { + 169 │ [].sort((a, b) => void a.fn()); + 170 │ [].toSorted((a, b) => { i Add a return with a value to this callback. @@ -1750,16 +1566,16 @@ invalid.js:197:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:198:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:169:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to sort() iterable method should always return a value. - 196 │ [].sort(function(a, b) {}); - 197 │ [].sort(() => void null); - > 198 │ [].sort((a, b) => void a.fn()); + 167 │ [].sort(function(a, b) {}); + 168 │ [].sort(() => void null); + > 169 │ [].sort((a, b) => void a.fn()); │ ^^^^ - 199 │ [].toSorted((a, b) => { - 200 │ return; + 170 │ [].toSorted((a, b) => { + 171 │ return; i Add a return with a value to this callback. @@ -1767,16 +1583,16 @@ invalid.js:198:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:199:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:170:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 197 │ [].sort(() => void null); - 198 │ [].sort((a, b) => void a.fn()); - > 199 │ [].toSorted((a, b) => { + 168 │ [].sort(() => void null); + 169 │ [].sort((a, b) => void a.fn()); + > 170 │ [].toSorted((a, b) => { │ ^^^^^^^^ - 200 │ return; - 201 │ }); + 171 │ return; + 172 │ }); i Add a return with a value to this callback. @@ -1784,16 +1600,16 @@ invalid.js:199:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:202:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:173:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 200 │ return; - 201 │ }); - > 202 │ [].toSorted(function(a, b) { + 171 │ return; + 172 │ }); + > 173 │ [].toSorted(function(a, b) { │ ^^^^^^^^ - 203 │ return; - 204 │ }); + 174 │ return; + 175 │ }); i Add a return with a value to this callback. @@ -1801,53 +1617,53 @@ invalid.js:202:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:205:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:176:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 203 │ return; - 204 │ }); - > 205 │ [].toSorted((a, b) => { + 174 │ return; + 175 │ }); + > 176 │ [].toSorted((a, b) => { │ ^^^^^^^^ - 206 │ if (a > b) { - 207 │ return; + 177 │ if (a > b) { + 178 │ return; i Change this return so that it returns a value. - 206 │ if (a > b) { - 207 │ return; - > 208 │ } else if (a < b) { + 177 │ if (a > b) { + 178 │ return; + > 179 │ } else if (a < b) { │ - > 209 │ return; + > 180 │ return; │ ^^^^^^ - 210 │ } else { - 211 │ return 1; + 181 │ } else { + 182 │ return 1; i Change this return so that it returns a value. - 204 │ }); - 205 │ [].toSorted((a, b) => { - > 206 │ if (a > b) { + 175 │ }); + 176 │ [].toSorted((a, b) => { + > 177 │ if (a > b) { │ - > 207 │ return; + > 178 │ return; │ ^^^^^^ - 208 │ } else if (a < b) { - 209 │ return; + 179 │ } else if (a < b) { + 180 │ return; ``` ``` -invalid.js:214:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:185:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 212 │ } - 213 │ }); - > 214 │ [].toSorted((a, b) => { + 183 │ } + 184 │ }); + > 185 │ [].toSorted((a, b) => { │ ^^^^^^^^ - 215 │ if (a > b) { - 216 │ return; + 186 │ if (a > b) { + 187 │ return; i Add a return with a value to this callback. @@ -1855,16 +1671,16 @@ invalid.js:214:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:221:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:192:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 219 │ } - 220 │ }); - > 221 │ [].toSorted((a, b) => { + 190 │ } + 191 │ }); + > 192 │ [].toSorted((a, b) => { │ ^^^^^^^^ - 222 │ if (a > b) { - 223 │ throw new Error(); + 193 │ if (a > b) { + 194 │ throw new Error(); i Add a return with a value to this callback. @@ -1872,16 +1688,16 @@ invalid.js:221:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:228:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:199:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 226 │ } - 227 │ }); - > 228 │ [].toSorted(() => void null); + 197 │ } + 198 │ }); + > 199 │ [].toSorted(() => void null); │ ^^^^^^^^ - 229 │ [].toSorted((a) => void a.fn()); - 230 │ + 200 │ [].toSorted((a) => void a.fn()); + 201 │ i Add a return with a value to this callback. @@ -1889,15 +1705,15 @@ invalid.js:228:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━ ``` ``` -invalid.js:229:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:200:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × This callback passed to toSorted() iterable method should always return a value. - 227 │ }); - 228 │ [].toSorted(() => void null); - > 229 │ [].toSorted((a) => void a.fn()); + 198 │ }); + 199 │ [].toSorted(() => void null); + > 200 │ [].toSorted((a) => void a.fn()); │ ^^^^^^^^ - 230 │ + 201 │ i Add a return with a value to this callback. diff --git a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.js b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.js new file mode 100644 index 000000000000..6d47760c7e88 --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.js @@ -0,0 +1,19 @@ +// Tests for forEach with checkForEach enabled +[].forEach((a) => { + return a.fn(); +}); +[].forEach(function(a) { + return a.fn(); +}); +[].forEach((a) => { + if (a) { + return a.fn(); + } +}); +[].forEach((a) => { + if (a) { + return; + } + return a.fn(); +}); +[].forEach((a) => a.fn()); // arrow expression returning value diff --git a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.js.snap b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.js.snap new file mode 100644 index 000000000000..42a114aff95c --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.js.snap @@ -0,0 +1,152 @@ +--- +source: crates/biome_js_analyze/tests/spec_tests.rs +expression: invalidCheckForEachEnabled.js +--- +# Input +```js +// Tests for forEach with checkForEach enabled +[].forEach((a) => { + return a.fn(); +}); +[].forEach(function(a) { + return a.fn(); +}); +[].forEach((a) => { + if (a) { + return a.fn(); + } +}); +[].forEach((a) => { + if (a) { + return; + } + return a.fn(); +}); +[].forEach((a) => a.fn()); // arrow expression returning value + +``` + +# Diagnostics +``` +invalidCheckForEachEnabled.js:2:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━ + + × This callback passed to forEach() iterable method should not return a value. + + 1 │ // Tests for forEach with checkForEach enabled + > 2 │ [].forEach((a) => { + │ ^^^^^^^ + 3 │ return a.fn(); + 4 │ }); + + i Either remove this return or remove the returned value. + + 1 │ // Tests for forEach with checkForEach enabled + > 2 │ [].forEach((a) => { + │ + > 3 │ return a.fn(); + │ ^^^^^^^ + 4 │ }); + 5 │ [].forEach(function(a) { + + +``` + +``` +invalidCheckForEachEnabled.js:5:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━ + + × This callback passed to forEach() iterable method should not return a value. + + 3 │ return a.fn(); + 4 │ }); + > 5 │ [].forEach(function(a) { + │ ^^^^^^^ + 6 │ return a.fn(); + 7 │ }); + + i Either remove this return or remove the returned value. + + 3 │ return a.fn(); + 4 │ }); + > 5 │ [].forEach(function(a) { + │ + > 6 │ return a.fn(); + │ ^^^^^^^ + 7 │ }); + 8 │ [].forEach((a) => { + + +``` + +``` +invalidCheckForEachEnabled.js:8:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━━ + + × This callback passed to forEach() iterable method should not return a value. + + 6 │ return a.fn(); + 7 │ }); + > 8 │ [].forEach((a) => { + │ ^^^^^^^ + 9 │ if (a) { + 10 │ return a.fn(); + + i Either remove this return or remove the returned value. + + 7 │ }); + 8 │ [].forEach((a) => { + > 9 │ if (a) { + │ + > 10 │ return a.fn(); + │ ^^^^^^^ + 11 │ } + 12 │ }); + + +``` + +``` +invalidCheckForEachEnabled.js:13:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━ + + × This callback passed to forEach() iterable method should not return a value. + + 11 │ } + 12 │ }); + > 13 │ [].forEach((a) => { + │ ^^^^^^^ + 14 │ if (a) { + 15 │ return; + + i Either remove this return or remove the returned value. + + 14 │ if (a) { + 15 │ return; + > 16 │ } + │ + > 17 │ return a.fn(); + │ ^^^^^^^ + 18 │ }); + 19 │ [].forEach((a) => a.fn()); // arrow expression returning value + + +``` + +``` +invalidCheckForEachEnabled.js:19:4 lint/suspicious/useIterableCallbackReturn ━━━━━━━━━━━━━━━━━━━━━━━ + + × This callback passed to forEach() iterable method should not return a value. + + 17 │ return a.fn(); + 18 │ }); + > 19 │ [].forEach((a) => a.fn()); // arrow expression returning value + │ ^^^^^^^ + 20 │ + + i Either remove this return or remove the returned value. + + 17 │ return a.fn(); + 18 │ }); + > 19 │ [].forEach((a) => a.fn()); // arrow expression returning value + │ ^^^^^^ + 20 │ + + +``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.options.json b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.options.json new file mode 100644 index 000000000000..eaa0831a8297 --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalidCheckForEachEnabled.options.json @@ -0,0 +1,15 @@ +{ + "$schema": "../../../../../../packages/@biomejs/biome/configuration_schema.json", + "linter": { + "rules": { + "suspicious": { + "useIterableCallbackReturn": { + "level": "error", + "options": { + "checkForEach": true + } + } + } + } + } +} diff --git a/crates/biome_rule_options/src/use_iterable_callback_return.rs b/crates/biome_rule_options/src/use_iterable_callback_return.rs index 866a2b0db3b3..4db8b1d73de5 100644 --- a/crates/biome_rule_options/src/use_iterable_callback_return.rs +++ b/crates/biome_rule_options/src/use_iterable_callback_return.rs @@ -1,6 +1,22 @@ use biome_deserialize_macros::{Deserializable, Merge}; use serde::{Deserialize, Serialize}; -#[derive(Default, Clone, Debug, Deserialize, Deserializable, Merge, Eq, PartialEq, Serialize)] + +#[derive(Clone, Debug, Default, Deserialize, Deserializable, Merge, Eq, PartialEq, Serialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields, default)] -pub struct UseIterableCallbackReturnOptions {} +pub struct UseIterableCallbackReturnOptions { + /// If true, also check that callbacks to `forEach` do not return a value. + #[serde(skip_serializing_if = "Option::<_>::is_none")] + pub check_for_each: Option, +} + +impl UseIterableCallbackReturnOptions { + pub const DEFAULT_CHECK_FOR_EACH: bool = false; + + /// Returns [`Self::check_for_each`] if it is set. + /// Otherwise, returns [`Self::DEFAULT_CHECK_FOR_EACH`]. + pub fn check_for_each(&self) -> bool { + self.check_for_each + .unwrap_or(Self::DEFAULT_CHECK_FOR_EACH) + } +}