A new release of SublimeLinter (v1.4) is now available. This version implements an option to display a popup list of errors when saving a file. For more information, see the README.
SublimeLinter
>>> view.run_command("lint", "JavaScript")
Traceback (most recent call last):
File "./sublimelinter_plugin.py", line 482, in run_
File "./sublimelinter_plugin.py", line 547, in _run
File "./sublimelinter_plugin.py", line 235, in run_once
File "./sublimelinter/modules/javascript.py", line 47, in run
File "./sublimelinter/modules/javascript.py", line 42, in check
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/decoder.py", line 338, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Can you please report this in github? At least there we will get notified when there is a response. When you report it, please note whether this is happening with all javascript files or a particular file.
SublimeLinter has just been updated to v1.1 with the following new features:
-
The documentation has been expanded and consolidated into README.markdown.
-
The commands to control SublimeLinter are now in the Command Palette and only appear when they are relevant to the current view and the current settings.
-
The current view can be linted with the key equivalent Control+Command+l (OS X) or Control+Alt+l (Linux, Windows).
-
Renamed jshint_config to jshint_options to be consistent with terminology on jshint.com.
-
Objective-J will check for invalid ASCII if sublimelinter_objj_check_ascii setting is true.
-
Default settings are defined and documented in Base File.sublime-settings.
-
Added Preferences menu items to access package settings and key equivalents.
-
Added ability to specify a custom executable for non-built in linters.
-
Added ability to map a syntax to a language to support syntax variants such as “Python Django”.
-
During startup, linters indicate if they are built in or the path to their executable.
-
The pyflakes error message shows a column number that matches ST2 column numbers.
Enjoy!
I tried changing the executable path to my php.exe, however I can’t seem to get it to work. If I add it to, either, the “Base File.sublime-settings” in the Packages\SublimeLinter, or in the User folder, nothing happens. The get_executable just doesn’t seem to be picking up the “Base File”… at least in my instance. I tried renaming the Base File.sublime-settings to something like “Linter.sublime-settings”, and then changing the get_executable load_settings to pick up this one, and it worked. Any ideas?
It works, you must not be using the right path. Here’s what my user settings look like:
“sublimelinter_executable_map”:
{
“php”: “c:/Program Files/PHP/php”
}
Very odd. I put:
"sublimelinter_executable_map":
{
"php": "C:/xampp/php/php"
}
into every occurrence of Base File.sublime-settings I could find (default, user, and the one in sublimelinter). Figured this would help me determine which Base File it was expecting to find it in. I put a “print map” statement in the module_utils.py to see what was happening and to make sure it wasn’t just me putting in an invalid path, and, unfortunately, it consistently shows “None”.
My original thought was it was something screwy about using “Base File” in the sublimelinter folder, since changing the name of the file from “Base File.sublime-settings” to “SublimeLinter.sublime-settings”, and then adjusting the module_utils.py file to reflect the same resolved the issue. But with you being able to get work makes things just that much more confusing. Thanks for checking.
I love this… but I wish I could turn off the outlining. It’s a bit too distracting as I’m typing.
Would also be nice to have an option where it ran a lint on every Save operation.
There are two options:
- Turn off background linting (see the README).
- Wait for a new version where I will implement a minimum delay, which will allow you to tell the linter to run only after a certain number of idle seconds has passed.
Good idea, I will add this as an option.
[quote=“dlprice”]Very odd. I put:
"sublimelinter_executable_map":
{
"php": "C:/xampp/php/php"
}
into every occurrence of Base File.sublime-settings I could find (default, user, and the one in sublimelinter). Figured this would help me determine which Base File it was expecting to find it in. I put a “print map” statement in the module_utils.py to see what was happening and to make sure it wasn’t just me putting in an invalid path, and, unfortunately, it consistently shows “None”.
My original thought was it was something screwy about using “Base File” in the sublimelinter folder, since changing the name of the file from “Base File.sublime-settings” to “SublimeLinter.sublime-settings”, and then adjusting the module_utils.py file to reflect the same resolved the issue. But with you being able to get work makes things just that much more confusing. Thanks for checking.[/quote]
I’ve tested this on windows and it does require some workaround. I finally got it working by editing both “Packages\SublimeLinter\Base File.sublime-settings” and “Packages\User\Base File.sublime-settings”…
With Packages\SublimeLinter\Base File.sublime-settings you must edit the portion where it says “sublimelinter_executable_map” by adding the necessary path. In my case where I have my php executable using XAMPP installation on D:/DEVIGN/xampp/php/php.exe I used:
"sublimelinter_executable_map":
{
"php": "d:/devign/xampp/php/php"
},
With Packages\User\Base File.sublime-settings you must insert the whole script (as seen above). On my case where I inserted it after my colors scheme setting it looks like this:
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"sublimelinter_executable_map":
{
"php": "d:/devign/xampp/php/php"
}
}
note: to avoid errors add a comma after the previous setting line before adding the script, and then make sure there is no comma between the last inserted setting script and the closing curly brace.
I’ve tested this on windows and it does require some workaround. I finally got it working by editing both “Packages\SublimeLinter\Base File.sublime-settings” and “Packages\User\Base File.sublime-settings”…
I can guarantee if you provide the correct path and don’t have any missing/extra commas in Packages\User\Base File.sublime-settings it will work correctly without modifying the default.
Hello
I cant get my SublimeLinter plugin to work This is what i get in my console when i save javascript file. I’ve installed node.js. I’m using Windows 7
Writing file /C/Users/Sosnowsd/AppData/Roaming/Sublime Text 2/Packages/SublimeLinter/Base File.sublime-settings with encoding UTF-8
reloading /C/Users/Sosnowsd/AppData/Roaming/Sublime Text 2/Packages/SublimeLinter/Base File.sublime-settings
Unable to open /C/Users/Sosnowsd/AppData/Roaming/Sublime Text 2/Packages/User/JSON.sublime-settings
Writing file /C/Users/Sosnowsd/AppData/Roaming/Sublime Text 2/Packages/SublimeLinter/Base File.sublime-settings with encoding UTF-8
reloading /C/Users/Sosnowsd/AppData/Roaming/Sublime Text 2/Packages/SublimeLinter/Base File.sublime-settings
Traceback (most recent call last):
File ".\SublimeLinter.py", line 259, in _callback
File ".\SublimeLinter.py", line 242, in _update_view
File ".\SublimeLinter.py", line 72, in background_run
File ".\SublimeLinter.py", line 87, in run_once
File ".\sublimelinter\modules\base_linter.py", line 270, in run
File ".\sublimelinter\modules\javascript.py", line 53, in parse_errors
File ".\json\__init__.py", line 307, in loads
File ".\json\decoder.py", line 319, in decode
File ".\json\decoder.py", line 338, in raw_decode
ValueError: No JSON object could be decoded
Writing file /C/Users/Sosnowsd/Work/patient-registry/lib/admin/client/tpl/doctor.tpl.js with encoding UTF-8
Traceback (most recent call last):
File ".\sublime_plugin.py", line 139, in on_post_save
File ".\SublimeLinter.py", line 520, in on_post_save
File ".\SublimeLinter.py", line 72, in background_run
File ".\SublimeLinter.py", line 87, in run_once
File ".\sublimelinter\modules\base_linter.py", line 270, in run
File ".\sublimelinter\modules\javascript.py", line 53, in parse_errors
File ".\json\__init__.py", line 307, in loads
File ".\json\decoder.py", line 319, in decode
File ".\json\decoder.py", line 338, in raw_decode
ValueError: No JSON object could be decoded
What is more strange, is that on the other machine, it’s working I have no other plugins installed.
Yes, of course. And it is added to PATH. Editor configuration is default, not changed
I love the idea of a built in linter in Sublime but have run into a bit of a problem.
I’ve been sniffing around in the source code and googled for a half day but can’t find anything anywhere, which makes me think that it might be impossible today. Could also be my google-fu that is weak so close to the holiday.
Is there a way to configure a project so SublimeLinter understands that some javascript variables are global and should not be errors in such a way that is implied on JSHint.com,
var result = JSHINT(source, options, globals);
/*global DISQUS:true, jQuery:false */
Is there a setting which takes care of this? Example below.
example.sublime-project
{
"settings":
{
"SublimeLinter":
{
"jshint_options":
{
// enforcing
"eqeqeq": true,
"immed": true,
"trailing": true,
"strict": true,
// relaxing
"evil": true,
"es5": true,
"regexdash": true,
"sub": true,
// environment
"browser": true,
"devel": true,
"wsh": false
},
// global
"jshint_global":
{
"sp": true,
"exports": true
}
}
}
}
Cheers,
gabbon