-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[ESLint] enable no-var rule
#3041
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
Conversation
|
|
|
||
| // Parse the search string to get url parameters. | ||
| var parameters = {}; | ||
| const parameters = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason I use var here is for browser compatibility. this file is not transpiled for browsers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is used for cypress, also every browser now supports let/const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not matter to this specific, but "every browser now supports [whatever]" does not account for users who are stuck on older versions, for whatever reason, plenty of which are valid. It is important to keep stock of what the actual user environment requirements are, and make them known, rather than silently relying on what "every browser now supports."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't need to teach lessons of usage var keyword in the script file, graphiql is bundled to esm and cjs with es5 target where var is used instead of let/const.
You should avoid using var in your code and give this work for bundlers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this example script has always been understood as file that is loaded without a bundler. the html may load a cdn bundled version of graphiql, but this code should run in any browser without any transpiler. many of graphiql's users use an approach such as this, just on jsdelivr about 550,000/month are served using the CDN bundle directly like this, and thus no transpiler is used. this would probably be much higher combined with unpkg stats if we had them, and which we now use in our documentation and is commonly referred to in examples when users have issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const and let have been fully supported by all modern browsers since the death of Internet Explorer, I think it should be fine to make this change: https://caniuse.com/?search=const
No description provided.