JSHint Error on Controller's static targets array definition

Hi everyone,

I’m getting started with Stimulus. I’m loving it since I have the feeling it hits the sweet spot on helping me organize the JS sprinkles I want to add to my projects in an elegant way, without having to add a complex framework (plus easy turbolinks compatibility).

I do have a question regarding the Controller’s targets array. I’m getting the following error from JSHint on that line:

E054 - Class properties must be methods. Expected '(' but instead saw '='.

I understand the intention from the handbook explanation of the targets array. But while looking for a way to get rid of this linter error I found this blog post saying this syntax is an ES7 proposal (?).

My question is whether or not anyone has dealt with this using JSHint? Because the JSHint project doesn’t support options to ignore errors I guess there’s nothing to do but deal with that error message on screen (JSHint lints for me since I use Atom).

Appreciate any advice, thanks!

You use a static get targets() method instead of a static targets property if you want to appease your linter. Example at: https://stimulusjs.org/handbook/installing#using-without-a-build-system.

Oh I see, I’m using webpack and I’m embarrased I didn’t pay enough attention to that section of the handbook. Thanks a lot for the clarification!