elicwhite / ESLint-Formatter

Sublime Text 3 Plugin to Autoformat with Eslint
MIT License
139 stars 20 forks source link

Can't convert 'NoneType' object to str implicitly #7

Open Djspaceg opened 8 years ago

Djspaceg commented 8 years ago

I installed this today, and I really like it! However, I keep getting errors like these. What additional debug information can I provide to help resolve this issue?

Unexpected error(<class 'TypeError'>): Can't convert 'NoneType' object to str implicitly
error: Can't convert 'NoneType' object to str implicitly

This is the eslinter output:

myFileName.js: line 3, col 8, Warning - 'SettingsUtils' is defined but never used (no-unused-vars)
myFileName.js: line 6, col 3, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 6, col 20, Warning - Missing space before function parentheses. (space-before-function-paren)
myFileName.js: line 7, col 5, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 8, col 7, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 9, col 7, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 10, col 7, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 14, col 3, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 14, col 23, Warning - Missing space before function parentheses. (space-before-function-paren)
myFileName.js: line 15, col 5, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 16, col 7, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 17, col 7, Warning - Expected indentation of 1 tab character but found 0. (indent)
myFileName.js: line 18, col 7, Warning - Expected indentation of 1 tab character but found 0. (indent)
elicwhite commented 8 years ago

What operating system are you using? Does the error output provide a line number or stack trace or anything that can help track it down in the formatter?

For these sublime plugins I'm much more likely to accept PRs that fix an issue than to actually get in there to get it sorted out. Perhaps by looking at the code and this error you might be able to track it down a bit more.

Djspaceg commented 8 years ago

Thanks for replying, @TheSavior. Mac OS X 10.11, and no, sorry it didn't include line numbers or any other information. I have SublimeLinter debugging enabled. Does ESLint-Formatter have any similar config to enable more verbose error output?

I'm afraid I don't know python, and would only cause more harm than good if I went mucking through the code. Sorry.

tony1223 commented 8 years ago

I have same issue. OSX 10.11.5 , sublime build 3114 .

I installed the plugin , click the "ESlinkt formatter" > "format this file" and the error comes in the console.

Unexpected error(<class 'TypeError'>): Can't convert 'NoneType' object to str implicitly error: Can't convert 'NoneType' object to str implicitly

I cant get any more detail information because there's no more detail i could get.

I think it would be better if you could print the stacktrace in your error handler function .

    except:
      # Something bad happened.
      msg = str(sys.exc_info()[1])
      print("Unexpected error({0}): {1}".format(sys.exc_info()[0], msg))
      sublime.error_message(msg)
pixelass commented 7 years ago

Any news on this issue?

OS X 10.12.1 (16B2657) Sublime Build 3126

Console output

Unexpected error(<class 'TypeError'>): Can't convert 'NoneType' object to str implicitly
error: Can't convert 'NoneType' object to str implicitly
elicwhite commented 7 years ago

I would be happy to accept a pull request if someone can figure this out

schmidtk commented 7 years ago

This seems to happen when the plugin doesn't have a file to process. I notice it when I save a file, get sublime linter warnings on save, and run the formatter with the warnings still displayed. If I simply close the warnings so the file has focus again, the formatter runs fine.

I get the same error with any other sublime popup open, like Ctrl+P or Ctrl+Shift+P, and also if I run the formatter with an empty column focused.

Hope this helps narrow it down in case someone wants to look into a solution.

lazamar commented 6 years ago

In OSX I fixed it by removing my custom config of eslint_path and node_path in Eslint-Formatter settings. I had these settings because I imported my config from my Linux installation. In the object I only specified paths for linux but still it was interfering with my OSX installation somehow.