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

No warning on unsupported methods missing object name #395

Closed
gabriele-cannizzaro opened this issue Aug 23, 2020 · 7 comments · Fixed by #561
Closed

No warning on unsupported methods missing object name #395

gabriele-cannizzaro opened this issue Aug 23, 2020 · 7 comments · Fixed by #561

Comments

@gabriele-cannizzaro
Copy link

gabriele-cannizzaro commented Aug 23, 2020

It looks like the plugin can't identify the unsupported use of a method call that doesn't include the class name:

'string'.repeat(5); // false negative
new String().repeat(5); // ! ESLint: String.repeat() is not supported in IE 11 (compat/compat)

In this case the first use of repeat() is not flagged as incompatible with IE, while the second one is. Is there a way to flag any use of incompatible methods on string literals?


EDIT: changed the above to reflect the much clearer rewrite by @HansBrende in the comment below. Original:

It looks like the plugin can't identify the unsupported use of a method call that doesn't include the object name:

image

In this case the first use of repeat() is not flagged as incompatible with IE, while the second one is. Is there a way to flag any use of incompatible methods?

@diegocr
Copy link

diegocr commented Nov 11, 2020

Same here...someone at my team used the es2021's replaceAll() method and there was no warning thrown from ESLint, the code ended up in production and disaster happened...

Moreover, i have just tried that String.repeat(5) here and i am not even getting a warning, nothing, which is very odd...using latest public releases of every npm package at time of writing. 🤔

May i ask what's your config @gabriele-cannizzaro ? Here's my browserlist and config

@yoyo837
Copy link

yoyo837 commented May 4, 2021

Same with @diegocr in production. So sad.

@ljharb
Copy link
Collaborator

ljharb commented May 4, 2021

String.repeat is not a thing that exists, so it would be just as weird for something to lint against it as to lint against String.yogurt.

@gabriele-cannizzaro
Copy link
Author

Sorry @ljharb, I might have misunderstood your comment, but what do you mean by "String.repeat is not a thing that exists"?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat

@HansBrende
Copy link

@gabriele-cannizzaro hmm, I'm gonna go out on a limb here and guess that by "String.repeat is not a thing that exists", he means "String.repeat is not a thing that exists".
Screen Shot 2022-01-11 at 7 06 42 AM

@HansBrende
Copy link

HansBrende commented Jan 11, 2022

@ljharb for clarity, let's pretend OP said:

It looks like the plugin can't identify the unsupported use of a method call that doesn't include the class name:

'string'.repeat(5); // false negative
new String().repeat(5); // ! ESLint: String.repeat() is not supported in IE 11(compat/compat)

In this case the first use of repeat() is not flagged as incompatible with IE, while the second one is. Is there a way to flag any use of incompatible methods on string literals?

Now the issue at hand is clear.

@gabriele-cannizzaro
Copy link
Author

@HansBrende thank you for the rewrite, that makes it indeed much clearer. Re-reading my original post and the thread I was obviously confusing things :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants