Module: ZendeskAppsSupport::Validations::Source

Defined in:
lib/zendesk_apps_support/validations/source.rb

Constant Summary collapse

LINTER_OPTIONS =
{
  # enforcing options:
  :noarg => true,
  :undef => true,

  # relaxing options:
  :eqnull => true,
  :laxcomma => true,

  # predefined globals:
  :predef => %w(_ console services helpers alert JSON Base64 clearInterval clearTimeout setInterval setTimeout)
}.freeze

Class Method Summary collapse

Class Method Details

.call(package) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zendesk_apps_support/validations/source.rb', line 21

def call(package)
  source = package.files.find { |f| f.relative_path == 'app.js' }

  return [ ValidationError.new(:missing_source) ] unless source

  jshint_errors = linter.lint(source.read)
  if jshint_errors.any?
    [ JSHintValidationError.new(source.relative_path, jshint_errors) ]
  else
    []
  end
end