I have a function that returns an array with 2 values. In this instance, I only want to use the first one. However, I cannot figure out the way that is accepted by ESLint to accomplish this.
I've tried the following ways, but there does not seem to be a way to satisfy all the rules.
// Triggers no-unused-vars rule
const [fileName, _] = createFile(objects, fileDirectory);
// Triggers comma-spacing rule
const [fileName,] = createFile(objects, fileDirectory);
// Triggers array-bracket-spacing rule
const [fileName, ] = createFile(objects, fileDirectory);
I would expect at least one of the methods to not trigger an ESLint rule violation, or there to be a different valid way of achieving the same.
const [fileName] = createFile(objects, fileDirectory);
?[fileName,]
and[fileName, ]
both do the same thing but in both cases it's useless - you are taking the first value and skipping the second. You'd do the skip thing only need to use for something like[fileName, , thirdValue]
- taking the first and third value skipping the second one.