roblox-ts / eslint-plugin-roblox-ts

7 stars 6 forks source link

Incorrect + infinite auto fix for lua-truthiness rule #11

Open osyrisrblx opened 5 years ago

osyrisrblx commented 5 years ago

The following code creates the bug:

const map = new Map<string, number>();
const x = map.get("foo");
if (!x) {
    throw "Couldn't find x!";
}

On line 3, ESLint reports:

0, NaN, and "" are falsy in TS. If intentional, disable this rule by placing `"roblox-ts/lua-truthiness": "off"` in your .eslintrc file in the "rules" object.eslint(roblox-ts/lua-truthiness)

Auto-fixing that line, results in: if (!x !== undefined) { (which is incorrect, should be if (x === undefined) {) But that auto-fix results in the same issue and will infinitely add more !== undefined

i.e.

if ((((!x !== undefined) !== undefined) !== undefined) !== undefined) {