Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
How to satisfy "no-param-reassign"?

I have a list of items. Some have children and I need to mutate the object into a certain shape then return it. However, I'm getting a no-param-reassign error. Is there a better way I could go about this to prevent this error?

items.map(item => {
  if (item.child) {
    item.child = transformItem(item.child);
  }
});

return transformItem(result);

Edit to add whole function:

async getItemById(itemId: string) {
  try {
    const result = await this.connector.get(`/items/${itemId}/item`);
    items.map(item => {
      if (item.child) {
        item.child = transformItem(item.child);
      }
    });
    return transformItem(result);
  } catch (error) {
    throw new Error(error.message);
  }
}
const transformItem = item => ({
  id: item['id'],
  someItem: item['some_item'],
  ...
});

The purpose of transformItem is to convert all keys to camelCase instead of snake case. Perhaps there is a better way of going about this that'd prevent be from mutating it in place?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!