Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
osyrisrblx opened this issue Oct 31, 2019 · 0 comments
Open

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

osyrisrblx opened this issue Oct 31, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@osyrisrblx
Copy link
Member

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) {
@osyrisrblx osyrisrblx added the bug Something isn't working label Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant