Skip to content

Commit

Permalink
Differentiate undef defaults for JSLint/JSHint
Browse files Browse the repository at this point in the history
  • Loading branch information
rondevera committed Aug 8, 2012
1 parent 88273d4 commit 9cedd62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions HISTORY
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Support/lib/jslintmate.rb
Expand Up @@ -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:
#
Expand Down
21 changes: 11 additions & 10 deletions Support/lib/jslintmate/linter.rb
Expand Up @@ -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(?:(.+?))?$/
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9cedd62

Please sign in to comment.