victorporof / Sublime-JSHint

JSHint Gutter for Sublime Text 2 and 3 via node.js
https://github.com/victorporof/Sublime-JSHint
682 stars 71 forks source link

ValueError: invalid literal for int() with base 10: 'NaN' #128

Closed xeroxoid closed 8 years ago

xeroxoid commented 8 years ago

Hi, first of all thanks for this awesome package!

Now I'm not seeing any errrors for camelcase: true and initially I thought that the .jshintrc file used was not the correct one (in my client directory). The I set "print_diagnostics": true in the JSHint settings file and saw that the linting options are correct, i.e.:

Using JSHint options: {
  "browser": true,
  "esnext": false,
  "strict": false,
  "undef": true,
  "unused": false,
  "bitwise": true,
  "camelcase": true,
  "curly": true,
  "eqeqeq": true,
  "es3": false,
  "forin": true,
  "freeze": true,
  "immed": true,
  "indent": 2,
  "latedef": "nofunc",
  "newcap": true,
  "noarg": true,
  "noempty": true,
  "nonbsp": true,
  "nonew": true,
  "plusplus": false,
  "quotmark": "single",
  "maxparams": 10,
  "maxdepth": 5,
  "maxstatements": 40,
  "maxcomplexity": 8,
  "maxlen": 120,
  "asi": false,
  "boss": false,
  "debug": false,
  "eqnull": true,
  "evil": false,
  "expr": false,
  "funcscope": false,
  "globalstrict": false,
  "iterator": false,
  "lastsemic": false,
  "laxbreak": false,
  "laxcomma": false,
  "loopfunc": true,
  "maxerr": false,
  "moz": false,
  "multistr": false,
  "notypeof": false,
  "proto": false,
  "scripturl": false,
  "shadow": false,
  "sub": true,
  "supernew": false,
  "validthis": false,
  "noyield": false,
  "node": true
}

I am also getting some strange error in the console output, namely:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 568, in run_
    return self.run(edit, **args)
  File "/Users/blah/Library/Application Support/Sublime Text 3/Packages/JSHint Gutter/JSHint.py", line 54, in run
    hint_point = self.view.text_point(int(line_no) - 1, int(column_no) - 1)
ValueError: invalid literal for int() with base 10: 'NaN'

Here are some screenshots of sublime as proof:

Code (no error shown on gutter): screen shot 2016-02-23 at 21 06 38

Output from my grunt linter: screen shot 2016-02-23 at 21 07 02

Any ideas on if this is a bug or a configuration issue?

victorporof commented 8 years ago

Doesn't look like the jshint options are incorrect. I bet ValueError: invalid literal for int() with base 10: 'NaN' is the actual error. I unfortunately can't reproduce this locally though :(

byterider commented 8 years ago

I have the same error (and linting doesn't work at all):

Traceback (most recent call last):
  File "/Applications/Sublime Text 3.app/Contents/MacOS/sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "/Users/ces/Library/Application Support/Sublime Text 3/Packages/JSHint Gutter/JSHint.py", line 54, in run
    hint_point = self.view.text_point(int(line_no) - 1, int(column_no) - 1)
ValueError: invalid literal for int() with base 10: 'NaN'

and when I insert the following, the error goes away (and linting works again): // jshint camelcase: false

byterider commented 8 years ago

This fix works for me (in ~/Library/Application Support/Sublime Text 3/Packages/JSHint Gutter/JSHint.py, line 54): hint_point = self.view.text_point(int(line_no) - 1, int(column_no if column_no != "NaN" else "1") - 1)