Class: Jshint::Lint
- Inherits:
-
Object
- Object
- Jshint::Lint
- Defined in:
- lib/jshint/lint.rb
Overview
Performs the linting of the files declared in our Configuration object
Instance Attribute Summary collapse
-
#config ⇒ Jshint::Configuration
readonly
The configuration object.
-
#errors ⇒ Hash
readonly
A Hash of errors.
Instance Method Summary collapse
-
#get_json(hash) ⇒ String
Converts a Hash in to properly escaped JSON.
-
#initialize(config_path = nil) ⇒ void
constructor
Sets up our Linting behaviour.
-
#lint ⇒ void
Runs JSHint over each file in our search path.
Constructor Details
#initialize(config_path = nil) ⇒ void
Sets up our Linting behaviour
19 20 21 22 |
# File 'lib/jshint/lint.rb', line 19 def initialize(config_path = nil) @config = Configuration.new(config_path) @errors = {} end |
Instance Attribute Details
#config ⇒ Jshint::Configuration (readonly)
Returns The configuration object.
13 14 15 |
# File 'lib/jshint/lint.rb', line 13 def config @config end |
#errors ⇒ Hash (readonly)
Returns A Hash of errors.
10 11 12 |
# File 'lib/jshint/lint.rb', line 10 def errors @errors end |
Instance Method Details
#get_json(hash) ⇒ String
Converts a Hash in to properly escaped JSON
42 43 44 |
# File 'lib/jshint/lint.rb', line 42 def get_json(hash) MultiJson.dump(hash) end |
#lint ⇒ void
This method returns an undefined value.
Runs JSHint over each file in our search path
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jshint/lint.rb', line 27 def lint javascript_files.each do |file| file_content = get_file_content_as_json(file) code = %( JSHINT(#{file_content}, #{}, #{jshint_globals}); return JSHINT.errors; ) errors[file] = context.exec(code) end end |