$div.hasClass();In their place, it suggests the following:hasClass();
div.hasClass();No, it doesn't. It says that our code is clever enough to not think that these false positives are issues that you need to fix. It's not saying you should use a method called hasClass(); it's saying that you should maintain state inside JS; this is principally a performance/code smell test.If your code is triggered from a non-JS DOM (e.g. painted from PHP), the first time you grab state from the DOM is unavoidable (and so you'd use an inline disable), but thereafter you should keep track of such details in JS. An example of this is in the initialisation code for Notifications ("Echo"), where it has to grab the state from the DOM for a couple of items, but does so only once.Sorry that this is confusing! We could put together a narrow JS tips and tricks page and link to that from the linter, but most of these have been fixed over the years since we introduced this in Wikimedia production code so there's not been much call.J.
MediaWiki-l mailing list -- email@example.com
List information: https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/