Alex
Alex

Reputation: 12049

coffeescript + jshint = Unused variable: _this

Compiling any code with bare = false and linting it with JShint
results in Unused variable: _this.

Solutions to this?
bare = true should remain,
besides I'm pretty happy to have jshint checking for unused variables. I just want an exception here.


By the way, I also get the

Move the invocation into the parens that contain the function.
}).call(this);

Upvotes: 0

Views: 722

Answers (3)

Dave Sag
Dave Sag

Reputation: 13486

I use the following .jshintrc settings in my browser-facing Coffeescript projects

// be sure to turn off 'devel' before shipping.
{
  "devel": true,
  "bitwise": true,
  "boss": true,
  "browser": true,
  "camelcase": true,
  "curly": true,
  "eqeqeq": true,
  "eqnull": true,
  "es3": false,
  "esnext": true,
  "forin": false,
  "freeze": true,
  "immed": true,
  "indent": 2,
  "jquery": true,
  "latedef": true,
  "newcap": true,
  "noarg": true,
  "noempty": true,
  "nonbsp": true,
  "nonew": true,
  "plusplus": false,
  "quotmark": "double",
  "strict": false,
  "trailing": true,
  "undef": true,
  "unused": false,
  "predef": ["jQuery", "console"]
}

Upvotes: 0

mar10
mar10

Reputation: 14804

If you really want to run the generated JS through JSHint, you can pass options to ignore this warnings like so:

###jshint node: true, unused: false ###

which compiles to

/*jshint node: true, unused: false */

Upvotes: 0

placeybordeaux
placeybordeaux

Reputation: 2216

Why are you running stuff you have written in Coffeescript through jshint? Isn't jshint supposed to be used with handwritten javascript?

If you really want to use a lint tool why don't you use http://www.coffeelint.org/

Lastly this is very similar to the question here, which was closed as not being a real question.

Upvotes: 1

Related Questions