1

Need to get rid of this warning without disabling the eslint. How do I remove a specific property from an JavaScript object? Something like:

const { foo, ...rest } = myObject;

I am seeing this warning:

'for' is assigned a value but never used.eslint@typescript-eslint/no-unused-vars

I want to get rid of this warning, is there any other solution for omitting the properties?

Ubaid
  • 737
  • 8
  • 18
  • 1
    you can find a good answer here: https://stackoverflow.com/questions/56151661/omit-property-variable-when-using-object-destructuring#answer-56151883 – bogdan Oct 06 '22 at 07:51
  • Is there any other way, or disabling the eslint is the only way to do it? – Ubaid Oct 06 '22 at 07:58

2 Answers2

0

It depends on the eslint configuration. There are two ways to remove the warning.

  1. Configure your eslint to not show warnings on unused variables. Set "no-unused-vars": "off" in . eslintrc. json

  2. Rename the "foo" variable to "_foo". (This might or might not work depending on the eslint configuration)

Subham Jain
  • 301
  • 3
  • 9
0

If you just want to get rid of the warning, you can use

/* eslint-disable @typescript-eslint/no-unused-vars */

at the top of your file

amm98d
  • 1,997
  • 2
  • 9
  • 15