Closed alexpyoung closed 10 years ago
What's your operating system and version.
Mac OS X 10.9.2
Does it run when you empty the JSLint User Settings? What version of JSLint does Package Control indicate you have?
Nope, same error.
Tools - Command Pallete - Package Control : List Packages; which version of JSLint?
Couldn't find a version number, but it looks like it was dated 8/26/2013
Run Tools-Command Palette - Package Control: Upgrade Packages
All my packages are currently upgraded
You should have JSLint v.2014.04.03.04.04.35 (under Tools - Command Palette - Package Control: List Packages)...?
Oops. Yes, that is the version I have.
MacOS worked for me so will need to dig deeper. Can you send your settings if they've been modified... will try to reproduce it.
Sublime User Settings?
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"detect_indentation": true,
"font_size": 14,
"ignored_packages":
[
],
"tab_size": 4,
"translate_tabs_to_spaces": true,
"use_tab_stops": true
}
I appreciate you taking time to look into it. Do you accept PayPal donations?
No, Preference - Package Settings - JSLint - Settings - Default and User
Default:
{
// an array of options to pass to jslint.
"options" : [
// examples using predef flag.
"--predef", "['angular', 'document', '\\$', '_', 'JQuery', 'FB']"
// tolerate missing 'use strict' pragma.
,"--sloppy"
// suggest an indent level of two spaces.
,"--indent", "2"
// assume node.js to predefine node globals.
,"--node"
// tolerate unfiltered for in.
//,"--forin"
// tolerate dangling _ in identifiers.
,"--nomen"
// tolerate many var statements per function.
,"--vars"
// tolerate ++ and --.
,"--plusplus"
// tolerate Douglas Crockford.
,"--stupid"
,"--todo"
]
// if true, run jslint on save.
,"run_on_save" : true
// a regex string to determine whether jslint
// should be run on a file.
// if a match is found (i.e. re.search(filename_filter, filename)),
// the file will be linted.
,"filename_filter": "(\\.js|\\.json|\\.html|\\.sass|\\.less|\\.html)$"
// jslint command you want to run as an array of strings.
// E.g.: ["jslint"] or ["/usr/local/bin/jslint"] or ["node", "mylinter.js"]
// Default is
// * Linux: ["node", "~/.config/sublime-text-2/Packages/JSLint/linter.js"]
// * Mac: ["node", "~/Library/Application Support/Sublime Text 2/Packages/JSLint/linter.js"]
// * Windows: ["node", "%APPDATA%/Sublime Text 2/Packages/JSLint/linter.js"]
// ,"jslint" : ["jslint"]
// if your own personal choice of jslint has an output
// different from the standard which comes with this package,
// you may have to change line_regex and file_regex
// check http://docs.sublimetext.info/en/latest/reference/build_systems.html
// to find out how these regular expressions work. The defaults are:
// ,"line_regex" : ".*// Line ([0-9]*), Pos ([0-9]*)$"
// ,"file_regex" : "(^[^# ]+.*$)"
}
User settings are empty
Both these files exist on your system? /Users/Alex/Library/Application Support/Sublime Text 2/Packages/JSLint/linter.js /Applications/MAMP/htdocs/Project/assets/js/service.js
Yes, the error is not unique to any specific JavaScript file. Any file I try to run JSLint on produces the same error (different file name of course)
From the command line: which node
/usr/local/bin/node
Try copying the default settings to user settings and modify user settings ,"jslint": ["/usr/local/bin/node", "~/Library/Application Support/Sublime Text 2/Packages/JSLint/linter.js"]
After running it with the modified user settings:
module.js:340
throw err;
^
Error: Cannot find module '/Applications/MAMP/htdocs/Project/assets/js/~/Library/Application Support/Sublime Text 2/Packages/JSLint/linter.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
[Finished in 0.1s with exit code 8]
Can you paste the modified user settings?
{
// an array of options to pass to jslint.
"options" : [
// examples using predef flag.
"--predef", "['angular', 'document', '\\$', '_', 'JQuery', 'FB']"
// tolerate missing 'use strict' pragma.
,"--sloppy"
// suggest an indent level of two spaces.
,"--indent", "2"
// assume node.js to predefine node globals.
,"--node"
// tolerate unfiltered for in.
//,"--forin"
// tolerate dangling _ in identifiers.
,"--nomen"
// tolerate many var statements per function.
,"--vars"
// tolerate ++ and --.
,"--plusplus"
// tolerate Douglas Crockford.
,"--stupid"
,"--todo"
]
// if true, run jslint on save.
,"run_on_save" : true
// a regex string to determine whether jslint
// should be run on a file.
// if a match is found (i.e. re.search(filename_filter, filename)),
// the file will be linted.
,"filename_filter": "(\\.js|\\.json|\\.html|\\.sass|\\.less|\\.html)$"
// jslint command you want to run as an array of strings.
// E.g.: ["jslint"] or ["/usr/local/bin/jslint"] or ["node", "mylinter.js"]
// Default is
// * Linux: ["node", "~/.config/sublime-text-2/Packages/JSLint/linter.js"]
// * Mac: ["node", "~/Library/Application Support/Sublime Text 2/Packages/JSLint/linter.js"]
// * Windows: ["node", "%APPDATA%/Sublime Text 2/Packages/JSLint/linter.js"]
,"jslint": ["/usr/local/bin/node", "~/Library/Application Support/Sublime Text 2/Packages/JSLint/linter.js"]
// if your own personal choice of jslint has an output
// different from the standard which comes with this package,
// you may have to change line_regex and file_regex
// check http://docs.sublimetext.info/en/latest/reference/build_systems.html
// to find out how these regular expressions work. The defaults are:
// ,"line_regex" : ".*// Line ([0-9]*), Pos ([0-9]*)$"
// ,"file_regex" : "(^[^# ]+.*$)"
}
For the jslint property can you try replacing "~/" with "/Users/Alex/" ?
That fixed the issue! Would you mind quickly explaining your debugging thought process and why this solution solved the problem?
Just reading the error messages and process of elimination mainly. That last error is node complaining about not finding a module; the message seems to indicate a weird shell expansion taking place and substituting the tilde for your current working directory. I don't know if this is an issue for all recent Macs and not sure of long-term solution yet.
Hmm, do you think that tilde substitution might also have to do with modifications to my .bashrc
or .bash_profile
? I might have modified it at some point without fully understanding what I was doing
Possibly. echo ~; echo $HOME; file ~/.bashrc
could be informative.
echo ~; echo $HOME; file ~/.bashrc; file ~/.bash_profile
:
/Users/Alex
/Users/Alex
/Users/Alex/.bashrc: ASCII English text
/Users/Alex/.bash_profile: ASCII text
Could you beta test this: Replace the JSLint.py script with
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sublime
import sublime_plugin
import re
import os
EXEC_LINT = 'js_lint_exec'
SETTINGS_FILE = 'JSLint.sublime-settings'
class JsLintExecCommand(sublime_plugin.WindowCommand):
def run(self, files=[]):
settings = sublime.load_settings(SETTINGS_FILE)
self.window.run_command('exec', {
'cmd':
map(os.path.expanduser, settings.get('jslint', ['node', sublime.packages_path() + '/JSLint/linter.js'])) +
settings.get('options', []) +
files,
'line_regex': settings.get('line_regex', '.*// Line ([0-9]*), Pos ([0-9]*)$'),
'file_regex': settings.get('file_regex', '(^[^# ]+.*$)')
})
class JsLintOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
settings = sublime.load_settings(SETTINGS_FILE)
if settings.get('run_on_save', False) == False:
return
if re.search(settings.get('filename_filter'), view.file_name()):
view.window().run_command(EXEC_LINT, {
'files': [view.file_name()]
})
# Support calls to the old API of the JSLint package.
class JslintCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command(EXEC_LINT, {
'files': [self.window.active_view().file_name()]
})
and revert your user settings to the default.
This may not solve the /usr/local/bin path issue but should fix the tilde expansion.
It seems to be working with the modifications to the Python file and default User Settings
From node Mac OS X package installer:
The installation was completed successfully Node was installed at /usr/local/bin/node npm was installed at /usr/local/bin/npm Make sure that /usr/local/bin is in your $PATH.
To do this in your ~/.bashrc file add this line:
export PATH=/usr/local/bin:$PATH
You may want to add current directory's node_modules folder also, then the line would be:
export PATH=/usr/local/bin:./node_modules/.bin:$PATH
Will do. Thank you for your time
Updated package should be available shortly via Tools - Command Palette - Package Control : Upgrade Packages. Please upgrade and confirm the fix. Feel free to close if the issue is resolved. Cheers... thanks for helping to troubleshoot this.
My build system was working yesterday before you merged https://github.com/darrenderidder/Sublime-JSLint/pull/21. I updated the User Settings file as instructed and am now receiving the following error:
I can still run node from the command line with the 'node'. Any ideas of what's wrong?