We are using a cloud-based IDE to teach javascript programming to first-time coders. This IDE using jshint for linting, and allows us to override options via .jshintrc.
We are using the p5.js library in our curriculum. While p5 does many things that are unconventional style-wise, we've found it's still the best library to introduce students to javascript in an engaging and interactive way.
A typical p5.js "sketch" is a script that looks like this:
let screenWidth = 600; const screenHeight = 800; function setup() { // this function is called automatically by p5 createCanvas(screenWidth, screenHeight); } function draw() { // this function is called automatically every frame by p5 } With this script, jshint will throw warnings for setup() and draw() because they are defined and not used. However, the p5.js library "exports" these for us and uses the functions we've defined, so there's nothing wrong with the above script.
If I wanted to suppress this warning I could put /* exported: setup,draw */ somewhere in the file. However, this is a bit much to expect new learners to manage. There a dozens of other functions like this that p5 uses, so the learner must remember to add that function to the comment line each time. It adds a bit of cognitive load to have to explain why they need to do this.
The easiest solution we have right now is to simply disable the warning globally by setting unused to false in jshint. However, this isn't ideal because beginner students often misspell things while typing. For example, another such function is mouseMoved(). By defining this function in our script, p5 will call it automatically whenever the mouse is moved. However, if a student mistypes it as mousemoved() or MouseMoved(), it won't get executed, and they won't get any warning as to why (assuming we've disabled unused in jshint).
Is there a way to define these "exported" functions in the .jshintrc file? If so, we could simply put all the exported p5 functions in there without the student having to do this on their own.