diff --git a/HISTORY b/HISTORY index d7fdc8b..e157c05 100644 --- a/HISTORY +++ b/HISTORY @@ -10,6 +10,7 @@ JSLintMate TextMate 2. * FIX: Added unused variable warnings (if the option is enabled) to the quick mode tooltip. +* FIX: Differentiated default `undef` settings for JSLint and JSHint. 1.3 (2012-03-05) diff --git a/Support/lib/jslintmate.rb b/Support/lib/jslintmate.rb index da0e77b..fdab9ea 100644 --- a/Support/lib/jslintmate.rb +++ b/Support/lib/jslintmate.rb @@ -23,7 +23,7 @@ # 2. Options file (via `TM_JSLINTMATE_JSLINT_OPTIONS_FILE` or # `TM_JSLINTMATE_JSHINT_OPTIONS_FILE`) # 3. [deprecated] Custom bundle preferences (via `--linter-options`) -# 4. Default bundle preferences (via `JSLintMate::Linter.default_options`) +# 4. Default bundle preferences (via `JSLintMate::Linter#default_options`) # # To update jslint.js and jshint.js: # diff --git a/Support/lib/jslintmate/linter.rb b/Support/lib/jslintmate/linter.rb index 60a5fca..a91e956 100644 --- a/Support/lib/jslintmate/linter.rb +++ b/Support/lib/jslintmate/linter.rb @@ -6,11 +6,12 @@ module JSLintMate class Linter include OptionsFiles - # Use `default_options` instead of `DEFAULT_OPTIONS`. + # Use `default_options` instead of `DEFAULT_OPTIONS`. See also `jslint.json` + # and `jshint.json`. DEFAULT_OPTIONS = { - 'undef' => false # `true` if variables and functions need not be - # declared before use. - } + :jslint => { 'undef' => false }, + :jshint => { 'undef' => true } + }.freeze JSC_PATH = '/System/Library/Frameworks/' << 'JavaScriptCore.framework/Versions/A/Resources/jsc' LINT_REGEXP = /^(Lint at line )(\d+)(.+?:)(.+?)\n(?:(.+?))?$/ @@ -34,11 +35,6 @@ class Linter ### Class methods ### - def self.default_options - # Returns a hash representation of `DEFAULT_OPTIONS`. - @default_options ||= options_hash_to_string(DEFAULT_OPTIONS) - end - def self.runner_path @runner_path ||= JSLintMate.lib_path('runner.js') end @@ -109,15 +105,20 @@ def initialize(key, attrs={}) def to_s; name; end + def default_options + @default_options ||= DEFAULT_OPTIONS[key] + end + def default_path JSLintMate.lib_path("#{key}.js") end def runner_command(filepath) runner_path = JSLintMate::Linter.runner_path + default_options_string = Linter.options_hash_to_string(default_options) runner_options = { - '--linter-options-from-defaults' => Linter.default_options, + '--linter-options-from-defaults' => default_options_string, '--linter-options-from-bundle' => options_from_bundle, '--linter-options-from-options-file' => options_from_options_file }