Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
XO Lint Issue Using Promise.map unicorn/no-array-method-this-argument

I am using XO for linting my code, and I cannot figure out why this lint error is being reported for the following code...

import Promise from 'bluebird';

const handler = items => {
  return Promise.map(items, item => {
    return Promise.resolve(item);
  });
};

export default handler;

When I save this to lint-test.js, and then run the following command...

npx xo lint-test.js

I get this error...

lint-test.js:4:29
  ✖  4:29  Do not use the this argument in Array#map().  unicorn/no-array-method-this-argument

  1 error

The reference for this rule is here... https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-method-this-argument.md

I must be missing something simple. I know this is an oversimplified example, but of course, in my real code, I am doing something more interesting with "item".

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're calling a method named .map and passing more than one argument - this is all the rule is looking for. The ESlint rule doesn't understand that Promise is the bluebird library but thinks it's an array, and that you're calling the Array map method, where the second parameter is for the this argument (and which the warning says you shouldn't use).

It's a false positive.

Remove the rule from your settings, ignore it for that line, or make a PR to add an exception for Promise as the receiver of the method call.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda