Hello, I have the code: const queue = new Map();
But Map is undefed. Can anyone help?
Hello, I have the code: const queue = new Map();
But Map is undefed. Can anyone help?
Itâll just be a linter warning. So long as the code is valid, it will still work.
You can specify global variables at the top of your file to make this warning go away - see https://eslint.org/docs/user-guide/configuring#specifying-globals
Hello @Gareth,
Linter errors due to Specifying Globals can be confusing for beginners who just learned how to use libraries.
From a pedagogical point of view, shouldnât this rule (or maybe all linter rules) be turned off on a beginner friendly platform like Glitch?
Linter errors could still be activated with a .eslintrc file.
Weâve since updated our linting rules so this specific issue should no longer be a problem - my response was a work around useful at the time of posting.
However, Iâm interested to understand more about that perspective. Globals aside, linting would seem to be useful for beginners to reinforce learning correct syntax and avoiding confusing runtime issues resulting from incorrect syntax.
Hello Gareth,
it seems this rule is still active: see https://glitch.com/edit/#!/hello-ml5js?path=script.js:4:66
Globals aside, linting would seem to be useful for beginners to reinforce learning correct syntax and avoiding confusing runtime issues resulting from incorrect syntax
Agree, yet i believe that only true errors preventing running the script (like forgetting a ;
in a for loop, or a }
in a css file ) should show an error hint, while ESLint could show a warn hint.
This way beginners would know about their errors and could also learn about âbest practicesâ.
More over, ESLint messages can be confusing: in the case of the Specifying Globals rule âXXXâ is not defined, beginners donât understand that the message is in the context of this script (I imported my XXX correctly in my html file, why is XXX not found?). Message warning could be âXXX is not defined in this scriptâ.
Initiatives like Processing and p5.js are doing great work on trying to make errors more understandable for beginners: Friendly Error System for p5.js
Re-thinking ESLint messages could add even more friendliness to the already friendly platform that Glitch is.
I was referring specifically to the Map issue. But thanks for taking the time to provide that feedback. Iâll share it with the team to talk through!
This issue with Specifying Globals rule iseven more flagrant when using p5js: https://glitch.com/edit/#!/p5js-hello-p5-animation?path=sketch.js:2:9
Agree with the linting issues with the p5 library. Whatâs the best way to fix this so that we donât see all these linting errors in code using the p5.js library? Iâm working with some students to help them transfer code they wrote on Khan Academy over to run on Glitch using p5.js. The code works fine but all the lint errors are distracting
hi dave - youâll want to specify the global variables (including function names) at the top of the file so the linter doesnât put red dot errors alongside them throughout the code. for example:
/* global fill, text, rect */
or /*eslint no-undef: 0*/
to turn off this rule
Took the survey for how next glitch might look and this would be great to have a setting to turn eslint on/off 'cause this is really confusing for a lot of beginners (and Iâm speaking as a teacher with ~1500 new glitch users/year) @jenn
This is related to my answers 2 years ago, but I do understand