damian / jshint

Making it easy to lint your JavaScript assets in any Rails 3.1+ and Rails 4 application.
https://rubygems.org/gems/jshint
MIT License
11 stars 21 forks source link

support for unused: vars #42

Closed jondandois closed 7 years ago

jondandois commented 7 years ago

Maybe I am missing something, but it seems like unused: vars is not supported as per http://jshint.com/docs/options/#unused. is that right? I've got a few methods that are called by partials depending on certain actions so the js files where they are defined do not immediately call the methods.

damian commented 7 years ago

Hi @jondandois

Any configuration option supported by the underlying JSHint library is supported by this gem. To validate your particular use case, I added the following test which failed correctly on account of c being defined and not used.

It's obviously difficult for me to be prescriptive about your code, but have you tried being more granular with your jshint annotations, for example:

screen shot 2016-12-05 at 12 25 14

The above annotation to /* exported test */ indicates to jshint that the test function is declared, but not used yet, so it won't be flagged up as a potential error. Would that work for you?

jondandois commented 7 years ago

Damian, thanks for your comments. The / export foo / flag was what I was thinking of and works for my situation. Appreciate the help and thanks for maintaining this gem.

On Mon, Dec 5, 2016 at 7:27 AM, Damian Nicholson notifications@github.com wrote:

Hi @jondandois https://github.com/jondandois

Any configuration option supported by the underlying JSHint library is supported by this gem. To validate your particular use case, I added the following test which failed correctly on account of c being defined and not used.

https://camo.githubusercontent.com/3d17a136138ebbc409783573658051ca123308d5/687474703a2f2f7777772e696d672e64616d69616e6e6963686f6c736f6e2e636f6d2f312e5f76696d5f323031362d31322d30355f31322d30392d30332e706e67

It's obviously difficult for me to be prescriptive about your code, but have you tried being more granular with your jshint annotations, for example:

[image: screen shot 2016-12-05 at 12 25 14] https://cloud.githubusercontent.com/assets/34645/20884917/eb1b4e22-bae5-11e6-8bde-24ec8b8044ae.png

The above annotation to / export test / indicates to jshint that the test function is declared, but not used yet, so it won't be flagged up as a potential error. Would that work for you?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/damian/jshint/issues/42#issuecomment-264841969, or mute the thread https://github.com/notifications/unsubscribe-auth/AUIcUjLMdyhUDj0LVoTLy5IIWTRh1ViZks5rFANMgaJpZM4LC-wl .