8000 Rule proposal: warn against unused array iterator method return values · Issue #2509 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Rule proposal: warn against unused array iterator method return values #2509

@PSeitz

Description

@PSeitz

There are some function calls where the return value should not be ignored (like some, indexOf, concat, map, etc.) or the function call doesn't make sense. Would be nice to cover this with the no-unused-expressions lint. I did test the snippets below on current master, they both don't fail.

function foo(arr) {
  if (arr) {
    arr.some(el == 'myval'); // should be: return arr.some(el == 'myval');
  }
  return undefined;
}
function foo(arr) {
  var merged = arr.reduce(function (a, b) {
    a.concat(b);  // should be: return a.concat(b);
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0