6683aa8b10
Running multiple `rake` commands with `spring', such as `spring rake db:rollback` could cause a `NameError: uninitialized constant HamlLint::Linter`
26 lines
829 B
Ruby
26 lines
829 B
Ruby
# rubocop:disable Naming/FileName
|
|
# frozen_string_literal: true
|
|
|
|
unless Rails.env.production?
|
|
require_dependency 'haml_lint/haml_visitor'
|
|
require_dependency 'haml_lint/linter'
|
|
require_dependency 'haml_lint/linter_registry'
|
|
|
|
module HamlLint
|
|
class Linter::InlineJavaScript < Linter
|
|
include LinterRegistry
|
|
|
|
def visit_filter(node)
|
|
return unless node.filter_type == 'javascript'
|
|
|
|
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
end
|
|
|
|
def visit_tag(node)
|
|
return unless node.tag_name == 'script'
|
|
|
|
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
end
|
|
end
|
|
end
|
|
end
|