Skip to content

linter: promise/catch-or-return warning when result is returned #13167

@KieranP

Description

@KieranP

What version of Oxlint are you using?

1.12.0

What command did you run?

oxlint

What does your .oxlintrc.json config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "ignorePatterns": ["/node_modules", "/*.{js,ts}"],
  "plugins": ["eslint", "oxc", "typescript", "import", "promise", "unicorn"],
  "categories": {
    "correctness": "error",
    "nursery": "error",
    "pedantic": "error",
    "perf": "error",
    "restriction": "error",
    "style": "error",
    "suspicious": "error"
  }
}

What happened?

promise/catch-or-return is not liking the following snippet:

async function fetchBlobs() {
  const urlsToFetch = ['...']
  const blobPromises = urlsToFetch.map(async (url) =>
    fetch(url).then(async (res) => res.blob())
  )
  return Promise.all(blobPromises)
}

The result of res.blob() is returned to the map, which is then passed to Promise.all. So the value is being returned up the chain.

It is happy with the following, which is functionally identical:

async function fetchBlobs() {
  const urlsToFetch = ['...']
  const blobPromises = urlsToFetch.map(async (url) => {
    const response = await fetch(url)
    return response.blob()
  })
  return Promise.all(blobPromises)
}

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions