aladdin-add / eslint-plugin

autofix some errors reported by eslint rules.
107 stars 10 forks source link

no-unused-var rule creates invalid code (2) #57

Open laurent22 opened 5 years ago

laurent22 commented 5 years ago

Tell us about your environment

It changes this:

sqliteErrorToJsError(error, sql = null, params = null) {
    return error;
}

to this:

sqliteErrorToJsError(error, , ) {
    return error;
}
Nantris commented 3 years ago

Also creates invalid code like:

From:

const someFunc = debounce(arg => {...})

To:

const someFunc = debounce( => {...})

Should change to:

const someFunc = debounce(() => {...})
Nantris commented 3 years ago

Also the super mysterious case of a used var being left alone, but needlessly having the comma afterward removed.

From:

const { x, y, width, height } = this.state;
const newX = parseInt((x / prevWindow.width) * winWidth);

To:

const { x y, width, height } = this.state;
const newX = parseInt((x / prevWindow.width) * winWidth);

Edit: Actually, this happens a lot... Doesn't seem to handle destructuring assignments whatsoever.

Nantris commented 3 years ago

There are a lot more edge cases too... like at least 4 more issues. They all seem to be variations on what is perhaps the same underlying bug in the rule's logic though.