Import globals for library


#1

Hi folks,

I’m liking Glitch a lot and I’m putting together some curriculum projects tor teaching coding at the Richmond (BC) Public Library.

I’m using the P5 graphics library a lot, which brings in a bunch of pseudo-globals (they are only global within the preload, setup, and draw methods). To use this library, I have to add an extensive /* global */ comment to tell the linter about every P5 function I’m using. This can be overwhelming and confusing for new students.

What I would like is a way to tell the linter,to bring in all the symbols from the library I’m using, something like /* use p5 globals */.

Thanks, this is a great resource!


#2

You could have them put a /* eslint-disable no-undef */ comment at the start of the file. This will disable warnings for undefined variables.


#3

Yes, and I probably will go that route, but that’s the nuclear option. I’d like for beginners to get warnings for actually undefined variables, just not for variables defined in the library we’re using.